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

Fix useLocalStorage batch updates not working #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Xedon
Copy link

@Xedon Xedon commented Jun 10, 2024

useLocalStorage can not handle batch updates correctly, this PR will fix that.

It does not call the update function with the current state in the local storage.
It uses the last "rendered" state which will not work if you call the callback multiple times without react rendering the component between calls.

Here is an example sandbox which shows our usecase.

In this Menu top left of the app.
image

If you Click show all or hide all this will do batch updates on the useLocalStorage which will only toggle the last column and not all columns due to this bug.
image

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.

None yet

1 participant