react-localstorage-hoc

0.0.2 • Public • Published

react-localstorage-hoc

A higher order function that wraps React components saving their state in persistent localStorage. Similar to react-localstorage but implemented as a higher order component

Usage

npm install react-localstorage-hoc
import persist from 'react-localstorage-hoc'
 
class Counter extends React.Component {
  render() {
    let { counter } = this.state
    return (
      <div onClick={e => this.setState({ counter: counter + 1 })}>
        {'Clicked ' + counter + ' times'}
      </div>
    )
  }
}
 
export default persist(Counter)

Readme

Keywords

none

Package Sidebar

Install

npm i react-localstorage-hoc

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

132 kB

Total Files

8

Last publish

Collaborators

  • josephfrazier