Skip to content

Commit

Permalink
Moved svelte:component into key block
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhamjared committed Jan 3, 2024
1 parent 0fc4b1c commit 953f3c9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/svelte/src/Render.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
</script>

{#if $store.component}
<svelte:component this={component} {...props}>
{#each children as child, index (component && component.length === index ? $store.key : null)}
<svelte:self {...child} />
{/each}
</svelte:component>
{#key key}
<svelte:component this={component} {...props}>
{#each children as child, index (component && component.length === index ? $store.key : null)}
<svelte:self {...child} />
{/each}
</svelte:component>
{/key}
{/if}

0 comments on commit 953f3c9

Please sign in to comment.