-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Which project does this relate to?
Router
Describe the bug
I recently encountered an issue where the parent route sets a context value in beforeLoad, but the child route does not inherit it.
I've posted this in #3403 (reply in thread) previously.
Your Example Website or App
https://stackblitz.com/~/github.com/ImSingee/tanstack-router-bug-report-hauecq3w
Steps to Reproduce the Bug or Issue
- Go to
/, and the browser will redirect you to/loginat the first time - Click "Login", and the browser will set some state and redirect you to the
/feed/allpage - In the
/feed/allpage, it showsfeedId =(error) - See the router devtools, the context
feedIdexists in/feed/allbut not/feed/all/ - Refresh the page, it shows
feedId = "all"(expected)
(If you need, you can click the logout button and restart from the step 1 to see or inspect the situation again)
Expected behavior
In the step 3, it should show feedId = "all". In the step 4, the context in the /feed/all/ should be the same as /feed/all
Screenshots or Videos
Platform
- OS: macOS
- Browser: Chrome
- Version: 132.0.2957.140 (Official build) (arm64)
Additional context
I try my best to make the reproduce example minimal. But the trigger condition is indeed complex.
Most interesting, if change the last line of SyncProvider (/src/lib/sync/provider.tsx) from return <AContext.Provider value={db}>{children}</AContext.Provider>; to return children, the issue disappears.