Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

read stale value from a "derived" proxy #617

Closed
xiechao06 opened this issue Jan 6, 2023 · 0 comments
Closed

read stale value from a "derived" proxy #617

xiechao06 opened this issue Jan 6, 2023 · 0 comments

Comments

@xiechao06
Copy link

xiechao06 commented Jan 6, 2023

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?

@pmndrs pmndrs locked and limited conversation to collaborators Jan 6, 2023
@dai-shi dai-shi converted this issue into discussion #618 Jan 6, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant