1.0.1 • Published 5 years ago

unstated-storage v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

unstated-storage

package version package downloads standard-readme compliant package license make a pull request

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

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

1.0.1

5 years ago

1.0.0

5 years ago