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

[@mantine/hooks] fix infinite re-render of useLocalStorage hook #6019

Conversation

wuifdesign
Copy link
Contributor

@wuifdesign wuifdesign commented Apr 2, 2024

as the serialize prop was not memorized the setStorageValue function was created on each re-render - resulting in an infinite re-render loop.

After this fix it is still needed to memorize the serialize and deserialize if overwriting them in your own code.

fixes #6017

@wuifdesign wuifdesign changed the title fix infinite re-render of useLocalStorage hook [@mantine/hooks] fix infinite re-render of useLocalStorage hook Apr 2, 2024
@israelins85
Copy link
Contributor

@rtivital this commit fixes the real problem, please don't redo my commit, change the key is another real bug, the hook have to reload the value when key is changed.

@kenzaflow
Copy link

Please, merge this

@noxan
Copy link

noxan commented Apr 10, 2024

@rtivital could we please merge this fix? the latest published version 7.7.1 is literally broken and mantine is a such a great library :)

@rtivital
Copy link
Member

It is not a valid solution – it breaks rules of hooks. If serialize option changes from undefined to other function, it will cause an error of the amount of hook rendered by the parent component. The issue is resolved by rolling back previous PR.

@rtivital rtivital closed this Apr 11, 2024
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

Successfully merging this pull request may close these issues.

useLocalStorage causes infinite re-renders
5 participants