unstated-storage
v1.0.1
Published
Persist your unstated container in local or session storage
Downloads
6
Readme
unstated-storage
Persist your unstated container in local or session storage
Table of Contents
Install
This project uses node and npm.
$ npm install unstated-storage
$ # OR
$ yarn add unstated-storage
Usage
import { StoredContainer } from 'unstated-storage'
class Example extends StoredContainer {
state = {
count: 0
}
store = {
version: 1, // Check for matching version in storage to populate
// If omitted, will just call setState with state at key
storage: window.sessionStorage,
key: 'example'
}
increment () {
this.setState(currentState = ({...currentState, count: ++currentState.count}))
}
}
export default Example
Contribute
- Fork it and create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am "Add some feature"
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
License
MIT