react-localstorage-hooks
v1.0.2
Published
A collection of React hooks for reactively managing localStorage
Downloads
509
Maintainers
Readme
Installation
Documentation
useLocalStorageState
: creates reactive state variables synced with localStorage.useLocalStorageReducer
: similar touseReducer
but abstracted on top of localStorage.useLocalStorageSelector
: hook to select some data from localStorage that automatically updates when selected data changes.createLocalStorageDispatch
: creates a dispatch method that directly updates localStorage.
Usage
Make sure your project is using React 16.18.0 or above.
Install the package using
npm
oryarn
npm i react-localstorage-hooks
Import the hooks either using ES6 named imports:
import { useLocalStorageState } from 'react-localstorage-hooks';
or importing each hook directly from
lib
:import useLocalStorageState from 'react-localstorage-hooks/lib/useLocalStorageState/useLocalStorageState';
License
This package is licensed under MIT