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
functionfetchExample(){// I expected that data function bails out,// Example component is not executed,// route before navigating here is held active,// while /login starts "loading" in the backgroundif(notLoggedIn())returnnavigate('/login');const[user]=createResource(...);return{user: user};}functionExample(){// ERROR: Cannot destructure property 'user' of as it is undefinedconst{ user }=useRouteData();// ...}
It looks like the navigation is started and return returns to component still.
For example if I changed the logic at the beginning of fetchExample to this:
if(notLoggedIn()){navigate('/login');return{};}const{ user }=useRouteData();// "useRouteData" returns empty object now
This feels like a bug to me. It doesn't happen on every navigation to /example but sometimes.
I use Suspense and all routes are transitioned.
What do you think? Am I wrong and it's expected due to the "concurrent" nature of this?
If that's the case, what would you recommend to make it as pleasant and logical as possible?
Guard each data read? Run createResource even if navigate is called?
All these options don't make me too happy honestly.
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
Uh oh!
There was an error while loading. Please reload this page.
-
Anyone else encountered the "issue" where route
component
still runs ifdata
navigates?For example this route:
It looks like the navigation is started and
return
returns to component still.For example if I changed the logic at the beginning of
fetchExample
to this:This feels like a bug to me. It doesn't happen on every navigation to
/example
but sometimes.I use
Suspense
and all routes are transitioned.What do you think? Am I wrong and it's expected due to the "concurrent" nature of this?
If that's the case, what would you recommend to make it as pleasant and logical as possible?
Guard each data read? Run
createResource
even ifnavigate
is called?All these options don't make me too happy honestly.
Beta Was this translation helpful? Give feedback.
All reactions