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
Today was my turn to be caught out by this issue, in which navigating from a dynamic route (my/route/[id].svelte) to the same route but with a new id caused... no new data to be loaded. There's a long chain of issues related to the same issue, which go all the way back to 552 and the Sapper era and broadly, the feedback is now: you have before/afterNavigate lifecycle functions, use those if you're ever going to be navigating between instances of the same dynamic route.
One thing that makes it harder to catch the issue, when you're writing this code, is the era of page endpoints - by which I mean, not having to write load functions because they are automatically enabled. As a result, I don't have a function kicking around I could easily re-use; instead, I have to repopulated a bunch of variables if they're already instantiated after each afterNavigate. And now I'm back to writing all the boilerplate Page Endpoints were largely supposed to save me from - and it took me longer to debug because I had embraced the magic and not even thought about writing a load function.
I don't know what the right answer is, let alone what the SvelteKit-y answer is, but the tangle is real, and now I either have some pages with explicit load functions (and some without), or I just go through and write all the boilerplate everywhere for consistency and clarity.
Or: is there a better approach to everything that I'm missing?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Today was my turn to be caught out by this issue, in which navigating from a dynamic route (
my/route/[id].svelte
) to the same route but with a newid
caused... no new data to be loaded. There's a long chain of issues related to the same issue, which go all the way back to 552 and the Sapper era and broadly, the feedback is now: you havebefore/afterNavigate
lifecycle functions, use those if you're ever going to be navigating between instances of the same dynamic route.One thing that makes it harder to catch the issue, when you're writing this code, is the era of page endpoints - by which I mean, not having to write
load
functions because they are automatically enabled. As a result, I don't have a function kicking around I could easily re-use; instead, I have to repopulated a bunch of variables if they're already instantiated after eachafterNavigate
. And now I'm back to writing all the boilerplate Page Endpoints were largely supposed to save me from - and it took me longer to debug because I had embraced the magic and not even thought about writing a load function.I don't know what the right answer is, let alone what the SvelteKit-y answer is, but the tangle is real, and now I either have some pages with explicit
load
functions (and some without), or I just go through and write all the boilerplate everywhere for consistency and clarity.Or: is there a better approach to everything that I'm missing?
Beta Was this translation helpful? Give feedback.
All reactions