0.0.2 • Published 7 years ago

react-localstorage-hoc v0.0.2

Weekly downloads
21
License
MIT
Repository
github
Last release
7 years ago

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)