-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Nested routing (<Routes> inside <RouterProvider />) #10317
Comments
This is as expected. According to the docs, "If you're using a data router like The error you're getting is because |
@timdorr Thanks for the clarification and quick response. React-router notifies us if we try to use nested But, if we use instead nested I suppose the react-router team rethinked the router and concentrates on the new router v6 approach as it is recommended router now and further. React-router v6 based on For me would be a very suitable possibility if you can declare multiple route configs as many as you needed and create for example: core root routing, nested header routing, and nested footer routing This would allows you to declare three As a conclusion: If we need something similar to "nested routes" we need to create our own "custom routes component" and according to current location load the proper "component". |
I think this is what I am also experiencing, though I'm not positive. I read this guide to
I can't find any caveats on that page about how the use of a |
I pulled this example down and I think there's an actual bug in here so I'm going to re-open this. There's some confusion around the usage of
|
Related discussion with similar confusion: #10373 |
This is fixed by #10374 and will be available once React Router 6.11.0 is released. |
🤖 Hello there, We just published version Thanks! |
Hi everyone, the issue has been solved, thank you |
wait... is that allowing an |
ah... the relative routes building is different when you're in a |
@jasikpark Nice catch, I believe " Let's have a look at an example from docs: And what are the types for What I am thinking is that " But if we trying create our own nested routes like this one: We got typescript IntelliSense for allowed properties, but it's the wrong properties, I think that " As mentioned @timdorr "The error you're getting is because does not read the errorElement (or loader) prop from your s and is essentially passing null to the browser router. This is partially from some internal implementation details, but combining the two APIs and structures together is not recommended anyways." I believe we can get a lot of different issues here because "combining the two APIs and structures together is not recommended anyways" and this a reason why I conclude "If we need something similar to "nested routes" we need to create our own "custom routes component" and according to current location load the proper "component"." because if it's not recommended officially we can't use it for production |
I think this needs some clarification, as this is not an accurate statement. I've tried to clarify some of the confusion here and here. To try to summarize:
We are working on better docs for this |
🤖 Hello there, We just published version Thanks! |
Uh, so when using (Or is the new system simply incompatible with encapsulation?) |
@qwertie Hello, I believe Here is the link where on v6.10 ![]() |
The "Data APIs" do not (and can not) work in If you want error boundaries in <BrowserRouter>
<Routes>
<Route element={<MyErrorBoundary><Outlet/></MyErrorBoundary>}>
...
</Route>
</Routes>
</BrowserRouter> https://codesandbox.io/s/wizardly-feynman-mxvpnt?file=/src/index.js |
Is https://reactrouter.com/en/main/route/lazy the main way to allow splitting routes into separate files? |
For Let's please stop using this closed issue as a Q&A forum and open new Q&A discussions for questions moving forward. |
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.
The text was updated successfully, but these errors were encountered: