Describe the problem
Dependencies are always unclear in Svelte, and Svelte 5 has causes some new infinite loops as mentioned in #13192. See also #12908.
Describe the proposed solution
Just like useEffect in React, I would like to use the optional second argument of the $effect rune to specify dependencies and untrack other states:
$effect(() => {
// your logic
}, [a, b, c]);
Basically this is a shorthand of:
$effect(() => {
void a;
void b;
void c;
untrack(() => {
// your logic
});
});
(I usually use void to explicitly specify dependencies)
Importance
would make my life easier