`useLocalStorage` not updating if many components watch the same key
- Dominant language
- TypeScript
- Stars
- 557
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Hey! Thanks for the awesome project. I’m having a problem where multiple calls to `useLocalStorage('my-key')` from different components are not staying in sync as the value changes.
## Reproduction
I’ve reproduced it in this sandbox:
https://codesandbox.io/s/distracted-bash-x9k10?file=/pages/index.js
## Expected behavior
If my `localStorage` value changes, all my components watching that value pick up the change.
## Actual behavior
The hook seems to be initializing from `localStorage` into individual instances of `useState` and then never reading from `localStorage` again.
Contributor guide
Research direction
Start with the linked CodeSandbox reproduction, especially pages/index.js, and inspect the useLocalStorage hook implementation in the repository. Confirm how separate hook instances respond when the shared localStorage key changes; done means all components watching the key update consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100