import {
setlocalStorageItem,
useLocalStorage,
} from '@progfay/use-local-storage'
const KEY = 'RANDOM_VALUE'
const ComponentA = () => (
<button onClick={() => setLocalStorageItem(Math.random().toFixed(10))}>
Set random value for localStorage
</button>
)
const ComponentB = () => {
const randomValue = useLocalStorage(KEY)
return (
<p>
random value in localStorage: {randomValue}
</p>
)
}
const App = () => (
<>
<ComponentA />
<ComponentB />
</>
)-
Notifications
You must be signed in to change notification settings - Fork 0
React hooks to manage state that works with `localStorage`
License
progfay/use-local-storage
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
React hooks to manage state that works with `localStorage`
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published