1.0.0 • Published 2 years ago

electron-localstorage-store v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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 store
  • updateStore: a function, using to update store
  • resetStore: a function, using to reset store (defaultValue is required)

Note: if you want to use resetStore, the defaultValue is required.

License

MIT @ syt-honey