Add option to disable the error boundary or bubble "outside of the router" #10166
Replies: 12 comments 16 replies
-
Not thowing the error means that in development my app does not fail and send the stack trace to the terminal. This means that all of the IDE work that has gone into processing stack traces and linking to the correct sites is useless. Am I doing something wrong? Is this really the intended behaviourin development? How does everybody else use react-router while they develop? Just watching the errors printed on the html? |
Beta Was this translation helpful? Give feedback.
-
I second the request. We cannot use it atm, as the routes are intercepting the errors displaying default ErrorBoundary of the RR. We have tried adding a top level error boundary via:
But it does not work, we are still seeing the default handler on routes in modules that are not direct children of the above browser router (they are rendered as While I appreciate the default error handling, there should be a way to disable that and wrap app in our own boundary. At the moment is is more of a hindrance than aid. |
Beta Was this translation helpful? Give feedback.
-
Just re-throw the error.
This seems to work properly |
Beta Was this translation helpful? Give feedback.
-
Upvote. Would like to see this be implemented. |
Beta Was this translation helpful? Give feedback.
-
Support this configuration and hope to implement it soon, It is now implemented through hacks |
Beta Was this translation helpful? Give feedback.
-
This would be helpful! Need it as we use |
Beta Was this translation helpful? Give feedback.
-
Upvote. We have global error handling via a common component library used by multiple apps/teams, and we all now have to implement a custom "hack" individually to handle errors at each route also |
Beta Was this translation helpful? Give feedback.
-
This is also a problem when using Storybook with their test-runner, because stories with errors no longer fail tests. |
Beta Was this translation helpful? Give feedback.
-
Have folks tried the solution proposed above to just re-throw from a root level boundary to get it outside the router? #10166 (comment) const router = createBrowserRouter([
{
path: '/'
Component: Root,
ErrorBoundary: () => {
throw useRouteError();
},
},
]); There is a separate concern of being able to gain access to the |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, this was my work arround to get access to error and info. Hope this help you guys |
Beta Was this translation helpful? Give feedback.
-
We're struggling with this as well, we have an isomorphic web application that renders a serviceable html version of the page On initial load. Unfortunately the ErrorBoundary driven solutions above insist on re-rendering and replacing a usable page with a non-usable one. I would like to simply allow the error to run it's course. This way, the error will get picked up by our logging, hydration will fail, and the initial html will continue to be displayed to the user who will click on to the next page without knowing anything went wrong.
I agree with this take, error handling seems outside the scope of a router and would be extremely easy to implement, but in it's current state it forces itself on all users. |
Beta Was this translation helpful? Give feedback.
-
I think that this (partial) error handling feature doesn't adhere to the separation of concerns principle. |
Beta Was this translation helpful? Give feedback.
-
Whilst the
errorElement
might be a nice addition, it's quite inconvenient when having customErrorBoundaries
in place or using one from another package like the AppInsightsErrorBoundary.An app-wide
ErrorBoundary
can't be used anymore because react-router will always catch it beforehand.So when having components outside of the router it basically requires two implementations (the "default one" and one using
useRouteError
)Crude suggestion
<RouterProvider router={router} disableErrorBoundary={true} />
Current workaround
Move the
<RouterProvider>
as high as possible and wrap the top-most route with the custom ErrorBoundary.Beta Was this translation helpful? Give feedback.
All reactions