Explain Svelte Action update and provide a reactive CSS example

Tests Svelte actions beyond initial mount. Strong answers explain update re-runs when parameters change, give a CSS custom properties example, and contrast with destroy. Red flag: suggesting the action re-runs from scratch or using reactive statements.
This tests whether you treat Svelte actions as long-lived lifecycle hooks, not one-time setup. A strong answer covers four things: first, the action runs once on mount; second, returning update reacts to parameter changes without teardown; third, a practical example like setting CSS custom properties via node.style.setProperty when a theme changes; fourth, destroy cleans up listeners. Red flag: claiming the action re-runs on every change, or using $derived inside instead of update.
Read the original → svelte.dev
- #svelte
- #actions
- #dom
- #lifecycle
- #advanced
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.