-
In a rather simple component, I have restProps (the rest of the properties). I need to run an effect whenever any property in this rest changes. $effect(() => {
const newProps = { ...restProps };
parcel?.update?.(newProps);
// parcel?.update?.({ ...restProps });
}); In order to have the above effect work (trigger on property changes), I have to have the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Cannot reproduce a difference in behavior. |
Beta Was this translation helpful? Give feedback.
-
Ok, I tried to reproduce in the REPL. I cannot. Still, in my project happens consistently. While the project is quite simple, because it is for micro-frontends, testing it requires 3 different projects, so I guess I'll let go for now. If anyone is curious, the project I speak of is this one. |
Beta Was this translation helpful? Give feedback.
-
Hello, everyone that might be remotely interested in the topic. After gaining more experience with Svelte v5 as well as a deeper understanding of how it works, I can finally explain what was happening to me. It is not a bug. Required KnowledgeEffects, when run, track the signals read while their functions execute. The built list of signals read is not fixed. This list is re-done every time the effect runs.. Effects run at least once, after component initialization, either before the UI updates ( The Problem In My CodeThe only signal in my effect is My component has another The correct thing to do here is to make |
Beta Was this translation helpful? Give feedback.
Hello, everyone that might be remotely interested in the topic. After gaining more experience with Svelte v5 as well as a deeper understanding of how it works, I can finally explain what was happening to me. It is not a bug.
Required Knowledge
Effects, when run, track the signals read while their functions execute. The built list of signals read is not fixed. This list is re-done every time the effect runs..
Effects run at least once, after component initialization, either before the UI updates (
$effect.pre
) or after.The Problem In My Code
The only signal in my effect is
restProps
. On the first run,parcel
is undefined, andparcel
is not reactive (not a signal). I am not showing that in …