useReducerWithLocalStorage
May 5, 2020 ยท View on GitHub
React hook that adds local storage support to the useReducer hook
Install
yarn add use-reducer-with-local-storage
Usage
const [state, dispatch] = useReducerWithLocalStorage({
initializerArg: emptyState,
key: 'REACT_APP_STATE',
reducer
});
Resources
-
https://gist.github.com/mattiaerre/8dbd2d8efca3f242c7085a9ce82ecbde
-
https://github.com/Tweries/silver-tip/blob/master/src/App.js#L2
Notes
- Special thanks to Matthew Brooks that was kind enough to review the original Gist and to propose new features.