useLocalStorage
Description#
Custom hook that works just like useState, but based on localStorage.
Usage#
import { 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;