Svelte · Senior · Question 10 of 75

Why must $effect be created inside a component or another effect, and what is $effect.root for?

Explanation

A root effect isn't cleaned up automatically, so you must call the returned cleanup function to avoid leaks.

Further reading

Problem with a question

Svelte · Senior · question 10

Test yourself

Take the Svelte · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz