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 complies with useState #242

Closed
wants to merge 1 commit into from

Conversation

valyrie97
Copy link

Fixes #204

  • add a test (that verified the issue)
  • changed the parameter of the setState callback function to get a fresh value from localstorage.

@henriqemalheiros
Copy link

Ran into the same issue. useSessionStorage also has this problem.

@valyrie97
Copy link
Author

valyrie97 commented Jan 5, 2023

@henriqemalheiros I'm happy to take a look at it and PR when i get a chance. could you create a separate issue and @ me?

@wayneschuller
Copy link

This bug is causing me headaches! Would love to see the PR accepted...

@juliencrn
Copy link
Owner

Thanks @valyrie97 that's perfect 👌
As the base branch is a bit outdated, I applied your change here #436 on both useLocalStorage and useSessionStorage

@juliencrn juliencrn closed this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useLocalStorage set function does not entirely comply with useState
4 participants