Closed nathggns closed 1 year ago
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders
@nathggns is attempting to deploy a commit to the Rooks Team on Vercel.
A member of the Team first needs to authorize it.
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 |
Thanks @nathggns this is super useful! I appreciate it 🤩
In https://github.com/imbhargav5/rooks/commit/adaaad1725977d539f5bda8c1fc8ee8358bd6a49#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 ofuseState
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.