-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Svelte 5: Sub-object losing reactivity #11069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note that you only have reactivity in I think this might be as intended. The proxy is only applied at the root. Generally when destructuring from something stateful, one should use const { settings } = $derived(context); This then also works for primitives: const { settings: { showInRgb } } = $derived(context); |
This definitely looks like a bug. My hunch — can't check right now — is that it's caused by this
We should probably just always run this logic, even if we're getting the value in a non-reactive context (i.e. during component init) |
#11102 is insufficient — we need to remove the check altogether, not replace it with |
Describe the bug
I'm not sure if this is intended behavior, so I'm reporting to make sure.
When you destructure a $state object to a primitive value it loses reactivity. That's to be expected.
But I assumed, that I would be able to destructure a sub-object, and maintain proper reactivity when modifying this object.
Reproduction
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE5WRTW-DMAyG_4oXTWorVXBPAWnaadddxw4thDYdJAibrVPEf18-oGVrVWmHHOzYfh-_NqyStUDG3wxT20Ywzp7alq0ZfbcuwE9Rk7Ax6r4rXCbBopMtZbnKSTat7ggMFFqROBEMUHW6gUUUj5koDIiOuNjMOp4Psi7PtT4aK0OZe3YCutkoiKTaox2eTkK5SuILh0p2PZFWoFVRy-IjNcsVpNm5M8KD_npRr_udnfBwnR38Mr4VzI1vpxYUglqgjzNrS6NLWUlRMk5dL4b12cXf-18MPeLcTHHydoRVJxNTeETaklgahzXxcPChTUxcHJymS1rCYXWPxhP_96ojz72bzu40cc6utPlzJk_Bb1p8Df8-_ABVkSoAnAIAAA==
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: