Component re-renders even no snapshot key is accessed #1142
Answered
by
dai-shi
xuxucode
asked this question in
Bug report
-
Bug DescriptionDoc at https://github.com/pmndrs/valtio?tab=readme-ov-file#react-via-usesnapshot mentioned that:
But in below example, when const state = proxy({ count: 0, text: "hello" });
// This will re-render on `state.count` or `state.text` change
function Counter() {
// `snap` is an unused variable
const snap = useSnapshot(state);
return <div>counter</div>;
}Is that expected? Reproduction Linkhttps://codesandbox.io/p/sandbox/valtio-countdown-to-do-list-forked-4zwh8m |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Jul 18, 2025
Replies: 1 comment 3 replies
-
|
Yes. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found it: #209