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

useLocalStorage() doesn't re-load from localStorage when key changes #7286

Closed
1 of 2 tasks
mfulton26 opened this issue Dec 19, 2024 · 1 comment
Closed
1 of 2 tasks
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@mfulton26
Copy link

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

7.15.1

What package has an issue?

@mantine/hooks

What framework do you use?

Vite

In which browsers you can reproduce the issue?

Chrome

Describe the bug

useLocalStorage() doesn't re-load from localStorage when key changes

as a workaround, a key prop can be used

image

oddly enough, if two usages of useLocalStorage() are used with the same key and the key prop workaround is used on the second one then the old value will flicker but will change while if it is used on the first one (like in the demo and screenshot) then the non-workaround value will not update even though it should

If possible, include a link to a codesandbox with a minimal reproduction

https://codesandbox.io/p/sandbox/mantine-react-template-forked-clnqdp

Possible fix

there may be some missing hook dependency that should use the incoming key value to the hook

Self-service

  • I would be willing to implement a fix for this issue
@rtivital rtivital added the Fixed patch Completed issues that will be published with next patch (1.0.X) label Dec 23, 2024
@rtivital
Copy link
Member

Fixed in 7.15.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants