Svelte slot props not reactive after initial render
0 reputation · 17 May 2025, 02:46 UTC
Slot Prop Reactivity Issue
In a Svelte 3.x component tree, a parent may expose a reactive variable to a child via a slot, e.g. <Child let:val>{val}</Child>. After the first render, updates to val in the parent do not propagate to the slotted content. The compiler evaluates slot props only once during component initialization, and the resulting function is not re‑invoked when the parent’s reactive value changes. This behavior is consistent across Vite, Rollup, and Webpack builds, and is documented as an open question in the Svelte issue tracker.
The goal is to determine whether this non‑reactivity is intentional for performance reasons, if it will be addressed in upcoming releases, and what patterns developers should adopt to keep slotted content in sync with parent state.
Unresolved Questions
- Will future Svelte releases change the compiler to re‑evaluate slot props on parent updates?
- What is the recommended pattern to keep slot content reactive without forcing a full re‑render of the parent?
- Can build‑time flags or compiler options enable automatic slot prop re‑evaluation?