Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@nathggns
Copy link
Contributor

In adaaad1#diff-b0add5bafe9b472c2eb73a766b1fde5062317a10e944f82725c1d782ccc7d6bf the possibility of using a function to generate the next state for useLocalstorageState was added. Unfortunately, this was done by adding the current value as a dependency of set, which meant its identity changed every time it is used. This is not the behaviour of useState and is not ideal – and most importantly its not necessary. We can just read the value from a ref instead.

This PR does that, and adds extra tests to ensure the identity of set (and remove) doesn't change when used.

@codesandbox
Copy link

codesandbox bot commented Apr 17, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@vercel
Copy link

vercel bot commented Apr 17, 2023

@nathggns is attempting to deploy a commit to the Rooks Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Apr 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooks ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2023 8:07am

@imbhargav5
Copy link
Owner

Thanks @nathggns this is super useful! I appreciate 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

Successfully merging this pull request may close these issues.

2 participants