electron-localstorage-store
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

electron-localstorage-store

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

Package Sidebar

Install

npm i electron-localstorage-store

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

8.3 kB

Total Files

7

Last publish

Collaborators

  • honeysyt