Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/progfay/use-local-storage
React hooks to manage state that works with `localStorage`
https://github.com/progfay/use-local-storage
localstorage react react-hooks
Last synced: 6 days ago
JSON representation
React hooks to manage state that works with `localStorage`
- Host: GitHub
- URL: https://github.com/progfay/use-local-storage
- Owner: progfay
- License: mit
- Created: 2023-08-02T14:18:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-02T14:25:29.000Z (over 1 year ago)
- Last Synced: 2024-12-03T17:56:35.553Z (2 months ago)
- Topics: localstorage, react, react-hooks
- Language: TypeScript
- Homepage: https://developer.mozilla.org/ja/docs/Web/API/Window/localStorage
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## `useLocalStorage(key)` hooks
__⚠️ This code has not yet been published in npm registry.__
```tsx
import {
setlocalStorageItem,
useLocalStorage,
} from '@progfay/use-local-storage'const KEY = 'RANDOM_VALUE'
const ComponentA = () => (
setLocalStorageItem(Math.random().toFixed(10))}>
Set random value for localStorage
)const ComponentB = () => {
const randomValue = useLocalStorage(KEY)
return (
random value in localStorage: {randomValue}
)
}const App = () => (
<>
>
)
```