Svelte · Middle · Question 6 of 75
What is the difference between $effect and $effect.pre?
- ✓Correct answer:
$effect.preruns before DOM updates (e.g. to save scroll position);$effectruns after the DOM is updated - 2
$effect.preruns on the server - 3
$effect.preruns only once
Explanation
$effect.pre replaces beforeUpdate from Svelte 4, and $effect replaces afterUpdate.