1.0.1 • Published 7 years ago
unstated-storage v1.0.1
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-storageUsage
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 ExampleContribute
- 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