Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setValue of useLocalStorage should not change at each rerender #118

Closed
alex-kowalczyk opened this issue Feb 25, 2022 · 1 comment
Closed

Comments

@alex-kowalczyk
Copy link

The setValue setter function returned by useLocalStorage is re-evaluated every time,
resulting in a lot of re-writes when it is specified as a dependency of an effect or callback (while skipping including it as dependency sometimes results in missing storage write).

I suspect it should be wrapped in something like useCallback(..., [setStoredValue]) to return a more "stable" object avoiding that issue.

@alex-kowalczyk alex-kowalczyk changed the title setter of useLocalStorage should be stable setValue of useLocalStorage should not change at each rerender Feb 25, 2022
@juliencrn
Copy link
Owner

Hi @alex-kowalczyk, good catch! Thanks for your feedback. I will fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants