Skip to content

useRemoveFromStore

This hook allows to remove a value from the Store.

import { useRemoveFromStore } from 'ra-core';
const remove = useRemoveFromStore();
remove(key);

The key should be a string, and is used to access local storage. It can be passed either when calling the hook, or when calling the callback:

const remove = useRemoveFromStore(key);
remove();
import { useRemoveFromStore } from 'ra-core';
const ResetPreferences = () => {
const removeItem = useRemoveFromStore();
return (
<>
<button onClick={() => removeItem('sidebar.open')}>
Reset sidebar
</button>
<button onClick={() => removeItem('locale')}>
Reset locale
</button>
<button onClick={() => removeItem('theme')}>
Reset theme
</button>
</>
);
};