Rendering behavior of defaultErrorComponent
vs notFoundComponent
inside the root route
#1107
Unanswered
GuillaumeLaroucheUQAT
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Throwing an error inside the component of a route will replace it by it's
errorComponent
or thedefaultErrorComponent
. However, throwing thenotFound()
function inside a loader will either replace the component by it'snotFoundComponent
or the entire route tree by thenotFoundComponent
defined inside the root route.Is there a way to define a default
notFoundComponent
that has the same behavior has thedefaultErrorComponent
? I've noticed that there's anglobalNotFound
property in the router options, but it doesn't seem to work likedefaultErrorComponent
.A current workaround is to duplicate the content of the component inside the
notFoundComponent
but it's not elegant.Example inside the
__root.tsx
:Maybe a solution could be to use the
InnerWrap
prop in the router options, but it would render the component on every route and limit the ability to replace the component based on the route in the future.Beta Was this translation helpful? Give feedback.
All reactions