useSnapshot and re-renders #279
-
Hey! Thanks again for this great package. I want to clarify one thing. For manual re-render subscriptions, I use the following construction: Now I am using this construction:
and everything works fine, but I want to clarify the difference between There is no difference in my understanding, but I'm not sure. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
useSnapshot(state).a.b
means subscribing tostate
and rendering if.a.b
changes.useSnapshot(state.a).b
means subscribing tostate.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 = ...
.