Svelte 5: how to correctly change the target.filters here?
#12405
Replies: 2 comments 4 replies
-
|
After you call the function, $effect(() => {
filteters = filtersParam.target.filters;
});which doesn't seem to be good. |
Beta Was this translation helpful? Give feedback.
-
|
From the little Svelte 5 code I've seen here it appears using an object with a Or you need to update -target.filters = JSON.parse(paramFilters);
+Object.assign(target.filters, JSON.parse(paramFilters));Edit: the second approach has the benefit of not triggering updates when nothing changes, because assigning the same value to a property will not trigger reactivity. Whereas reassigning a new object to Edit2: Well I guess you also need to clear the old keys before doing |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to create a little helper but I don't understand how to set
target.filtersin the below code to be able to see it in body and to execute$effect():Reproduction code
Beta Was this translation helpful? Give feedback.
All reactions