Skip to content

Navigating from /a to /b in route /[route] reruns +page.ts but +page.svelte is unchanged #15918

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

Closed
ianengelbrecht opened this issue May 14, 2025 · 5 comments

Comments

@ianengelbrecht
Copy link

ianengelbrecht commented May 14, 2025

Describe the bug

If I have a route like /[slug], and I go to /a, the page load function picks up 'a' from params, does what it needs and passes the data down to +page.svelte as expected. Then if I then navigate from /a to /b, the page load function reruns, provides new data down to +page.svelte, but the ui does not update. I can't find anything in the docs to describe what to do to get the ui to update with the new data.

Reproduction

https://github.com/ianengelbrecht/sveltekit-pagenavs

Logs

NA

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i5-1345U
    Memory: 16.37 GB / 31.66 GB
  Binaries:
    Node: 22.13.1 - C:\nvm4w\nodejs\node.EXE
    npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.89)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    svelte: ^5.0.0 => 5.29.0

Severity

annoyance

@Conduitry
Copy link
Member

Switching to another page that's rendered by the same component updates the props passed to that component - it doesn't re-render the whole component. const { stage } = data; isn't reactive when data changes. You can use $derived() to handle these changes.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2025
@ianengelbrecht
Copy link
Author

I've added a derived variable as I've understood your suggestion, but the ui still doesn't update. Example repo updated with this change.

@ianengelbrecht
Copy link
Author

Just to elaborate, my understanding is that derived variables must be based on reactive ($state()) variables, and since the values passed down from the pageLoad are not reactive we cannot use them for $derived.

@7nik
Copy link
Contributor

7nik commented May 15, 2025

It should be like this:

  const { data } = $props();
- const { stage } = data;
+ const { stage } = $derived(data);

Also, it should be noted that stage, in case it's an object, isn't deeply reactive.

@ianengelbrecht
Copy link
Author

ianengelbrecht commented May 15, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants