Are parent loaders always meant to overrule child loaders? #11357
Replies: 3 comments 3 replies
-
Is the <Route path="/id" loader={() => throw notfound()}>
<Route path="redirect" loader={() => throw redirect('example')}/>
<Route path="example" />
</Route> |
Beta Was this translation helpful? Give feedback.
-
Hi @stuartkeith I faced exactly this issue and I was puzzled. Do you have any updates? My situation is very similar:
The outcome is that the redirect is performed, which is not what I was expecting. If just for testing I replace the line in the parent loader that throws a 500 with a random redirect, the random redirect is performed. |
Beta Was this translation helpful? Give feedback.
-
There's a discussion in #11805 but I wanted to cross-post here that I believe what you all really want for these use cases is middleware which will let you do this type of top-down control flow. Please keep an eye on that proposal for updates. |
Beta Was this translation helpful? Give feedback.
-
Say I have the following routing setup:
/<id>
- will throw a 404 if id is not a number/<id>/redirect
- will throw a redirect to/<id>/example
/<id>/example
- a normal pageIf I go to
/123/redirect
, I am redirected to/123/example
as expected.But if I go to
/foo/redirect
, I am redirected to/foo/example
. I would expect a 404 instead - the parent loader will throw a 404 asfoo
is not a number. I can see the parent loader does throw the 404 as expected, but the child loader's redirect takes priority.This seems to be related to redirects specifically - if I had the child loader throw a 500 instead, the user gets the 404, the 500 is ignored.
I'm not sure if this is a bug or I'm misunderstanding how the parent/child loaders work together. Does anybody know what is going on here? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions