react-localstorage-hoc
v0.0.2
Published
A higher order function that wrap react components and saves it's state in persistent storage
Downloads
56
Readme
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)