Easy use localstorage in Reactjs
https://www.npmjs.com/package/reactjs-localstorage
npm install reactjs-localstorage
or
yarn add reactjs-localstorage
import {reactLocalStorage} from 'reactjs-localstorage';
reactLocalStorage.set('var', true);
reactLocalStorage.get('var', true);
reactLocalStorage.setObject('var', {'test': 'test'});
reactLocalStorage.getObject('var');
reactLocalStorage.remove('var');
reactLocalStorage.clear();
npm run test
reactLocalStorage.set(key, value)
reactLocalStorage.get(key, deafultValue=undefined, silent=true)
reactLocalStorage.setObject(key, object)
reactLocalStorage.getObject(key, defaultValue={}, silent=true)
reactLocalStorage.remove(key)
reactLocalStorage.clear()
silent:
true
: Will not throw exception instead will return defaultValuefalse
: Will throw exception
MIT