Svelte · Senior · Question 10 of 75
Why must $effect be created inside a component or another effect, and what is $effect.root for?
- ✓Correct answer: Effects belong to an owner that destroys them;
$effect.rootcreates a manually controlled scope for effects outside that lifecycle - 2
$effect.rootruns effects on the server - 3
$effect.rootmakes effects run first
Explanation
A root effect isn't cleaned up automatically, so you must call the returned cleanup function to avoid leaks.