electron-localstorage-store
v1.0.0
Published
A React hook for sharing and synchronization of data through `localStorage` in multi-window.
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-storeUsage
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, thedefaultValueis required.
License
MIT @ syt-honey
