react-local-signal-storage
v1.0.4
Published
React Hooks adapter for Local Signal Storage
Downloads
4
Maintainers
Readme
React Local Signal Storage
React Hooks adapter for Local Signal Storage
Provides the same as API as react-use useLocalStorage while keeping changes made in different components on the same page in sync.
Installation
yarn install local-signal-storage
Or
npm install local-signal-storage
Usage
import { useLocalSignalStorage } from 'react-local-signal-storage';
const Demo = () => {
const [value, setValue, remove] = useLocalSignalStorage('my-key', 'foo');
return (
<div>
<div>Value: {value}</div>
<button onClick={() => setValue('bar')}>bar</button>
<button onClick={() => setValue('baz')}>baz</button>
<button onClick={() => remove()}>Remove</button>
</div>
);
};