You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In dev mode, after I make a code change, the route component re-mounts itself but it never re-calls afterNavigate. This leaves things in an inconsistent state. Not a huge annoyance but I do have to do ctrl+R in development.
It's the Demo app from create-svelte, but extended to have a parameterized route. The final commit in the history just adds some console.log statements to see what's going on in the lifecycle events.
This one is tricky — since the component accepts the hot update, the main client.js has no opportunity to detect that that's happened and re-run afterNavigate functions that were added during the update. (The Vite client does emit events, but not the ones we need AFAICT.)
We can't just run afterNavigate functions as soon as they're registered, because that would incorrectly cause functions to run when a component was rendered outside a navigation.
I don't have any bright ideas for fixing this, but maybe someone with more Vite expertise would.
I ran into this issue as well, when trying to use before/afterNavigate to modify the session, containing a flash message that's displayed somewhere on the page after a POST, but should be cleared when navigating elsewhere.
Describe the bug
In dev mode, after I make a code change, the route component re-mounts itself but it never re-calls
afterNavigate
. This leaves things in an inconsistent state. Not a huge annoyance but I do have to do ctrl+R in development.Reproduction
Repro is this branch of this repo:
https://github.com/johnnysprinkles/sveltekit_after_navigate_bug/tree/after_nv
It's the Demo app from create-svelte, but extended to have a parameterized route. The final commit in the history just adds some
console.log
statements to see what's going on in the lifecycle events.To repro just clone that and run it with "npm run dev", and create some TODO items, then navigate to one of them (using the newly added "i" icon, or directly via URL e.g. http://localhost:3000/todos/4110e0d9-56a9-4106-9d83-1fada5087660
Now if you make an arbitrary change to routes/todos/[uid].svelte you'll see how onMount runs but afterNavigate doesn't. Looks like:
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: