Persistent state made easy
npm install --save react-use-persistent
import React, { Component } from 'react'
import { usePersistent } from 'react-use-persistent'
function MyComponent() {
const [ setting, setSetting ] = usePersistent("localstorage-key", false);
return (
<input type="checkbox" checked={setting} onChange={event => setSetting(event.target.checked)} />
)
}
MIT © EricRabil