Closed xiechao06 closed 1 year ago
mix-use of useState and valtio.derive will make the component read the stale value of the derived proxy.
https://codesandbox.io/s/valtio-mix-with-state-ielduu?file=/src/App.tsx
Though this example seems harmless, this inconsistency brokes my project (in the progress of migration from redux to valtio).
but it works fine if use valtio only, https://codesandbox.io/s/valtio-not-mix-with-state-2j4ocl?file=/src/App.tsx
BTW, I've tested jotai, it also works, https://codesandbox.io/s/brave-drake-qsvvz5?file=/src/App.tsx, would you suggest using jotai instead?
Summary
mix-use of useState and valtio.derive will make the component read the stale value of the derived proxy.
Link to reproduction
https://codesandbox.io/s/valtio-mix-with-state-ielduu?file=/src/App.tsx
Though this example seems harmless, this inconsistency brokes my project (in the progress of migration from redux to valtio).
but it works fine if use valtio only, https://codesandbox.io/s/valtio-not-mix-with-state-2j4ocl?file=/src/App.tsx
BTW, I've tested jotai, it also works, https://codesandbox.io/s/brave-drake-qsvvz5?file=/src/App.tsx, would you suggest using jotai instead?