diff --git a/packages/svelte/src/Render.svelte b/packages/svelte/src/Render.svelte index db30c2df4..f33cca93f 100644 --- a/packages/svelte/src/Render.svelte +++ b/packages/svelte/src/Render.svelte @@ -14,12 +14,23 @@ export let component export let props = {} export let children = [] + + let prevComponent + let key + $: { + if (prevComponent !== component) { + key = Date.now() + prevComponent = component + } + } {#if $store.component} - - {#each children as child, index (component && component.length === index ? $store.key : null)} - - {/each} - + {#key key} + + {#each children as child, index (component && component.length === index ? $store.key : null)} + + {/each} + + {/key} {/if}