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
{{ message }}
Repository navigation
Tanstack Router: Stale context in child routes #4546
Under certain conditions child route loaders receive stale or cached context data. For example given this structure:
_app.tsx -- which is layout pathless route
_app -- folder
index.tsx
$id.tsx
both index and $id routes use context as deps for their loaders, however they receive stale data when we navigate to either of routes, overall behavior is very consistently reproducible, so either I got something wrong with route hierarchy or it's a bug. This is observed both in router and start probjects
Land on Home (index) route, there are two timestamps visible, one in header accessed via Route.useRouteContext, another in index route that is accessed via Route.useRouterData
Spam on "Invalidate router" button to ensure both timestamps are updated and loader for index route runs fine. This is expected
Go to "Link to /1", land on $id route and click on the same Invalidate router button, timestamp from loaderData is not updated, in console we see that loader runs on every invalidate call, however it receives old data as context
Go to Home, now index route is also broken and gets old ctx data when clicking on Invalidate data
Expected behavior
As a user, I expect to receive fresh and latest ctx as my loader args, imagine having auth checks or some server-side stored user prefs that we use as deps for other loaders calls
Activity
fix: correctly handle pending vs. cached matches