-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
Which project does this relate to?
Router
Describe the bug
When using beforeLoad in nested routes, the expected behavior is that if a parent route’s beforeLoad function throws an error, the child routes’ beforeLoad functions should not be executed.
However, in the current behavior, even when the parent route’s beforeLoad throws an error, the beforeLoad of the child route is still invoked.
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-cu9mdexv
Steps to Reproduce the Bug or Issue
- Visit https://stackblitz.com/edit/tanstack-router-cu9mdexv
- Open console
- Navigate to the Posts route.
- Navigate to any Post.
- The post route throw an error, it's expected. But in the console you can see the console.warn from the post.index route.
Expected behavior
The child route’s beforeLoad should not be called if the parent’s beforeLoad throws.
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: Chrome
- @tanstack/react-router 1.120.3
- react 19.0.0
Additional context
The reproduction is forked https://tanstack.com/router/latest/docs/framework/react/examples/basic-file-based.
Changes:
- add
posts.$postId.index.tsx - add
beforeLoadto theposts.$postId.tsxandposts.$postId.index.tsx - remove defaultPreload: 'intent' from the
main.tsx
Possibly a related discussion
Possibly a related issue
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels