useLocalStorage
#
DescriptionCustom hook that works just like useState
, but based on localStorage
.
#
Usageimport { useLocalStorage } from '@springtree/eva-suite-react-hooks';
const Example = () => { const [storedValue, setValue] = useLocalStorage<string | undefined>( 'example-storage-key', undefined, );
return ( <input value={storageValue} onChange={(event) => setValue( event.target.value !== '' ? event.target.value : undefined )} /> )};
export default Example;