Skip to content

When setAtom in timeout or async function will update component twice and with different value #2797

Discussion options

You must be logged in to vote

if you use react v17, you will reproduce.

That's a known behavior. With v17, you need to use unstable_batchedUpdates for this case.

Check it out: https://stackblitz.com/edit/vitejs-vite-t8lzju?file=src%2FApp.tsx&terminal=dev

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@shenweizheng110
Comment options

@dai-shi
Comment options

@shenweizheng110
Comment options

@dai-shi
Comment options

Answer selected by shenweizheng110
@shenweizheng110
Comment options

@dai-shi
Comment options

@shenweizheng110
Comment options

@dai-shi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants