Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old page receives new page's props before swapping #2151

Open
mattwigham opened this issue Dec 24, 2024 · 0 comments
Open

Old page receives new page's props before swapping #2151

mattwigham opened this issue Dec 24, 2024 · 0 comments
Assignees
Labels
svelte Related to the svelte adapter

Comments

@mattwigham
Copy link

Version:

  • @inertiajs/svelte version: 2.0.0 and 1.3.0
  • svelte version: 5.16.0

Describe the problem:

When navigating from one page to another, the old page component is briefly updated with the new page's props before the new page component is swapped in. This causes undefined errors since the old page doesn't have its expected props any longer.

I'm not sure if this is expected behavior, or if it's specific to Svelte 5. This happens when using $props() and $page.props.

Steps to reproduce:

Create two pages link to each other and each receives unique props.

// One.svelte

<script>
  import { Link } from "@inertiajs/svelte";
  let { propOne } = $props(); // set to "prop-one-value" on the server
  $inspect("One", propOne);
</script>

<Link href="/two">Two</Link>
// Two.svelte

<script>
  import { Link } from "@inertiajs/svelte";
  let { propTwo } = $props(); // set to "prop-two-value" on the server
  $inspect("Two", propTwo);
</script>

<Link href="/one">One</Link>

In the browser, navigate using the links and you'll see the following in the console.

init One prop-one-value
update One undefined
init Two prop-two-value
update Two undefined
init One prop-one-value
...
@mattwigham mattwigham added the svelte Related to the svelte adapter label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
svelte Related to the svelte adapter
Projects
None yet
Development

No branches or pull requests

2 participants