Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4.6k
how to derive a deeply reactive variable from another?#16187
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
let's say I have a list of items
and I want adeeply reactive variable that's derived from it. it must:
the only way I currently know is using
https://svelte.dev/playground/5f8a2ab8ce1d4834a5ba16fce64fada6?version=latest
|
BetaWas this translation helpful?Give feedback.
All reactions
As has been mentioned in#16189, one can wrap the value in a$state
proxy to get deep reactivity in derived values.
$derived.by(()=>{letval=$state(...);returnval;});functionproxify(value){constproxified=$state(value);returnproxified;}letfoo=$derived(proxify(...));
Replies: 2 comments 3 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
As of Svelte 5.25.0, you can update deriveds and it just works: |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
it's not deeply reactive though: edit: nevermind the playground seems to be reactive |
BetaWas this translation helpful?Give feedback.
All reactions
-
Huh, this was not behaviour I was expecting though. Maybe you're right? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks, that was my mis-conclusion. I updated the title to have the word "deeply". |
BetaWas this translation helpful?Give feedback.
All reactions
-
As has been mentioned in#16189, one can wrap the value in a
|
BetaWas this translation helpful?Give feedback.