electron-localstorage-store
v1.0.0
Published
A React hook for sharing and synchronization of data through `localStorage` in multi-window.
Downloads
15
Maintainers
Readme
A React hook for sharing and synchronization of data through localStorage
in multi-window (Also works well in electron multi-window).
Install
# install pkg
pnpm install electron-localstorage-store
Usage
import { useLocalStorageStore } from 'electron-localstorage-store'
const [store, updateStore, resetStore] = useLocalStorageStore({
key: 'myUniqueKey',
defaultValue: { /** properties */ }
})
// use `updateStore` to update store
updateStore({ newField: 'newValue' })
// use `resetStore` to reset store
resetStore()
store
: current storeupdateStore
: a function, using to update storeresetStore
: a function, using to reset store (defaultValue is required)
Note: if you want to use
resetStore
, thedefaultValue
is required.
License
MIT @ syt-honey