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
Component being rendered before beforeLoad() has completed #1827
After setting up a simple app with authentication, when I log in, the beforeLoad() function does not complete before my route is rendered. This causes an error as the context does not contain values I expect.
Click on the second link 'Go to the auth-only dashboard page'
Enter a username and click 'Login'
After an expected delay an error occurs. Since the beforeLoad() has not completed, the value property has not been added to the context.
Expected behavior
I would expect the beforeLoad() to finish running before the loader() runs or the component is rendered.
Screenshots or Videos
No response
Platform
OS: Windows
Browser: Edge
Version: 126.0.2592.68 (Official build) (64-bit)
Additional context
This issue seems to happen in part due to the fact that when the user logs in, the InnerApp (in main.tsx) rerenders due to a state update in the AuthContext. This results in the RouterProvider being re-rendered. This re-render happens in addition to the call to router.navigate() from the login.
Reacted by Melvin Valster, Sarkis Kozanoghli, Mgrdich, TheTensaii, nitzan-sh, Mike Reczek and Igor Adrov
Activity
sarkis1231 commentedon Jul 1, 2024
I have the same issue
schiller-manuel commentedon Jul 6, 2024
this will be fixed by #1907
reproducer with pre-release package: https://stackblitz.com/edit/tanstack-router-ucnt94?file=src%2Froutes%2F_auth.dashboard.tsx
mindaugasb-isense commentedon Mar 20, 2025
It still happens some times. V. 1.111.7
schiller-manuel commentedon Mar 20, 2025
@mindaugasb-isense can you please create a new GitHub issue including a minimal complete example?