Reactivity of dynamic <svelte:component> props
See original GitHub issueDescribe the bug Spread props seem to loose reactivity when used in conjunction with dynamic component.
First reported on stack overflow: https://stackoverflow.com/questions/58262342/reactivity-of-dynamic-sveltecomponent-props?noredirect=1#comment102908014_58262342
To Reproduce https://svelte.dev/repl/c30956f32d514063b7694711a3637093?version=3.12.1
Expected behavior
I was expecting the Main
component to start with rendring the Banner
component, and then the Header
component. when the timeout expires.
- Svelte version (Please check you can reproduce the issue with the latest release!) Cf. REPL.
Severity Not a big issue, the switching I want can be done with if/then/else. That is actually what I do right now. But it would be pretty cool if you could switch a component AND its props at will. Example from the documentation shows how to switch component but only with static props.
Additional context
I basically wanted to select a component based on a route
parameter, and also to select the props for that component through the same logic.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
One note though, I wonder if the Svelte compiler could issue a warning when it sees props being used in an expression that is not made reactive with
$:
? Would be a nice-to-have thing, not really indispensable but still that may help.Alright, there is no bug there, I found where I went wrong in my original implementation mentioned in SO, I forgot a
$:
before one of the statement, so it was not reactive anymore… Closing this. Thanks for the help.