Replies: 2 comments 1 reply
-
Hi, this is one of the confusing points. state.obj = obj
// that ☝️ is actually this 👇
state.obj = proxy(obj)
// and proxy(obj) copies obj. So, to make your code work as expected, you would need to do something like this: const handleClick = () => {
state.obj = { aa: 33, bb: 200 };
setTimeout(() => {
state.obj.aa = 190;
state.obj.bb = 100;
}, 1000);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
-
It looks to me that Valtio does not support 're-set' an object/array to its proxy state.
In order to make my teammates understand this, and avoid this problem(set the same object twice), do you have any suggestion?
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
snap.obj.aa is always 33, it would not change to 190, why?
Beta Was this translation helpful? Give feedback.
All reactions