Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/null-none/react-localstorage
Easy methods for use localstorage in Reactjs.
https://github.com/null-none/react-localstorage
javascript js localstorage nodejs react reactjs
Last synced: 2 months ago
JSON representation
Easy methods for use localstorage in Reactjs.
- Host: GitHub
- URL: https://github.com/null-none/react-localstorage
- Owner: null-none
- Created: 2016-11-20T10:52:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-02T06:56:42.000Z (almost 2 years ago)
- Last Synced: 2024-10-28T16:56:37.854Z (3 months ago)
- Topics: javascript, js, localstorage, nodejs, react, reactjs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/reactjs-localstorage
- Size: 19.5 KB
- Stars: 21
- Watchers: 2
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# reactLocalStorage
Easy use localstorage in Reactjshttps://www.npmjs.com/package/reactjs-localstorage
## Installation
```bash
npm install reactjs-localstorage
```
or
```bash
yarn add reactjs-localstorage
```## Examples
```javascript
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
```bash
npm run test
```## API Guide
- `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 defaultValue
- `false`: Will throw exception## License
MIT## Donation Button
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YYZQ6ZRZ3EW5C)