Does object destructuring affect Valtio's useSnapshot re-render optimisation #707
Unanswered
codebycarlos
asked this question in
Q&A
Replies: 2 comments
-
Based on this, it appears the answer is no (doesn't affect optimisation). |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, it still works as intended (= render optimized.) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
According to the documentation:
"useSnapshot wraps the Valtio snapshot in an access-tracking proxy, so your component is render optimized, i.e. it will only re-render if keys that it (or its child components) specifically accessed have changed, and not on every single change to the proxy."
And the example..
My question is, if we replace the above with object destructuring (i.e.
const { count } = useSnapshot(state)
) would the optimisation still work as intended?Beta Was this translation helpful? Give feedback.
All reactions