-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
What version of React Router are you using?
6.10.0
Steps to Reproduce
Example:
I wrote a full example on Codesandbox for reproducing, please have a look:
https://codesandbox.io/s/react-router-v6-action-error-edbuhu?file=/src/business/business.js
Explanation:
I use <RouterProvider /> in the root,
but I have another router inside (for my header) where I show components (search, filtering, selectors) depending on routing.
Other words inside the root "Layout" component exist a "Header" component where exist nested routes <Routes><Route.../></Routes>
Steps for reproduce:
Press the button "Submit. Press and get an error." below on the page and get an error.
To fix the problem, comment in the opened file: (business/business.js file)
// export const APP_ENABLE_NESTED_ROUTES = true;
Conclusion:
Nested routes broke errorElement handling. Why?
Thanks for your attention,
Andrii Badekha
Expected Behavior
After pressing the button: "Submit. Press and get an error.",
Expect message on UI:
Exception properly handled in <PageError />
I expect that my "errorElement" will catch an error and process them, but instead, the react-router shows a general error, not my error handler component.
Actual Behavior
After pressing the button: "Submit. Press and get an error.",
Get the error:
Error: Could not find a matching route for the current errors: [object Object]
As a result, my errorElement was missed, I read additionally documentation and seems like it is unexpected behaviour, docs don't cover this case.
