Skip to content

Local update in the component that uses store causes an extra update from store #638

Answered by dai-shi
mahmutyilmazcs asked this question in Q&A
Discussion options

You must be logged in to vote

This is expected behavior. If it renders from parent or state, in this case useState, we need to run the render and commit, because bool in this case may change the result.

The difference between react 18 and pre-18 is also expected. It's because react 18 comes with automatic batching. To get the same behavior in pre-18, one would need to use unstable_batchedUpdates.

Replies: 1 comment 13 replies

Comment options

You must be logged in to vote
13 replies
@mahmutyilmazcs
Comment options

@greenwish84
Comment options

@dai-shi
Comment options

@mahmutyilmazcs
Comment options

@dai-shi
Comment options

Answer selected by mahmutyilmazcs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants