diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d3562620..48aec25f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ For changes prior to v1.0.0, see the [legacy releases](https://legacy.inertiajs. - Fix form helper `transform` return type in React adapter ([#1896](https://github.com/inertiajs/inertia/pull/1896)) - Use updater function in `setData` in `useForm` hook in React adapter ([#1859](https://github.com/inertiajs/inertia/pull/1859)) - Skip intercepting non-left button clicks on links ([#1908](https://github.com/inertiajs/inertia/pull/1908), [#1910](https://github.com/inertiajs/inertia/pull/1910)) +- [Svelte] Fix `` component to respect `preserveState` option ([#1943](https://github.com/inertiajs/inertia/pull/1943)) - [Svelte] Fix 'received an unexpected slot "default"' warning ([#1941](https://github.com/inertiajs/inertia/pull/1941)) ## [v1.2.0](https://github.com/inertiajs/inertia/compare/v1.1.0...v1.2.0) diff --git a/packages/svelte/src/lib/components/Render.svelte b/packages/svelte/src/lib/components/Render.svelte index 4fd9cb7e6..8c1e65e10 100644 --- a/packages/svelte/src/lib/components/Render.svelte +++ b/packages/svelte/src/lib/components/Render.svelte @@ -23,20 +23,17 @@ export let component: ComponentType export let props: PageProps = {} export let children: RenderProps[] = [] - - let prevComponent: ComponentType - let key: number - $: if (prevComponent !== component) { - key = Date.now() - prevComponent = component - } {#if $store.component} - {#key key} + + {#key children?.length === 0 ? $store.key : null} {#if children.length > 0} - {#each children as child, index (component && component.length === index ? $store.key : null)} + {#each children as child} {/each}