Skip to content

useSnapshot and re-renders #279

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

You must be logged in to vote

useSnapshot(state).a.b means subscribing to state and rendering if .a.b changes.
useSnapshot(state.a).b means subscribing to state.a and rendering if .b changes.
Technically, the latter can be more performant, because it's more granular subscription.
Only the former allows to mutate like state.a = ....

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nosferatu500
Comment options

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