-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hi,
While the storage event is fired when another page modifies local storage, it's not fired when the current page modifies local storage. Thus two components on the same page using this hook won't stay in sync. Demo codesandbox
The setState function should probably also be wrapped in useCallback to prevent its reference identity from changing on every render. This is consistent with the setter returned by useState and the dispatch function returned by useReducer, and allows for things like passing the function down in React context without causing components downstream to update constantly.
ypresto
Metadata
Metadata
Assignees
Labels
No labels