reactjs-localstorage
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/reactjs-localstorage package

1.0.1 • Public • Published

reactLocalStorage

Easy use localstorage in Reactjs

https://www.npmjs.com/package/reactjs-localstorage

Installation

npm install reactjs-localstorage

or

yarn add reactjs-localstorage

Examples

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();

Test

npm run test

API Guide

  • reactLocalStorage.set(key, value)
  • reactLocalStorage.get(key, deafultValue=undefined, silent=true)
  • reactLocalStorage.setObject(key, object)
  • reactLoacStorage.getObject(key, defaultValue={}, silent=true)
  • reactLocalStorage.remove(key)
  • reactLocalStorage.clear()

silent:

  • true: Will not throw exception instead will return defaultValue
  • false: Will throw exception

License

MIT

Donation Button

Donate

Dependents (14)

Package Sidebar

Install

npm i reactjs-localstorage

Weekly Downloads

4,296

Version

1.0.1

License

MIT

Unpacked Size

3.59 kB

Total Files

4

Last publish

Collaborators

  • null-none