Skip to content
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

[Feature]: nested path and catch all routes #8783

Closed
jdeniau opened this issue Apr 8, 2022 · 1 comment
Closed

[Feature]: nested path and catch all routes #8783

jdeniau opened this issue Apr 8, 2022 · 1 comment
Labels

Comments

@jdeniau
Copy link

jdeniau commented Apr 8, 2022

What is the new or updated feature that you are suggesting?

Ignore the catch all routes when matching absolute routes.

Why should this feature be included?

#7992 add the availability to declare absolute path for nested routes, this way we can do that :

const ROUTE_USER = '/users';
const ROUTE_USER_DETAIL = '/users/show/:id';
const ROUTE_USER_NEW = '/users/new';


<Route path={ROUTE_USER}>
  <Route path="" element={<UserList />} />
  <Route path={ROUTE_USER_DETAIL} element={<UserDetail />} />
  <Route path={ROUTE_USER_NEW} element={<UserNew />} />
</Route>

it's great, but if you do this:

const ROUTE_USER = '/users';
const ROUTE_USER_DETAIL = '/users/show/:id';
const ROUTE_USER_NEW = '/users/new';


<Route path={ROUTE_USER}>
  <Route path="*" element={<UserWrapper />}>
    <Route path="" element={<UserList />} />
    <Route path={ROUTE_USER_DETAIL} element={<UserDetail />} />
    <Route path={ROUTE_USER_NEW} element={<UserNew />} />
  </Route>
</Route>

Then the following error is thrown:

Absolute route path "/users/new" nested under path "/*" is not valid. An absolute child route path must start with the combined path of all its parent routes.

@jdeniau jdeniau added the feature label Apr 8, 2022
@timdorr
Copy link
Member

timdorr commented Apr 8, 2022

Wildcards aren't intended for nested routes. They're for trailing segments to indicate acceptance of further nested URLs. You would get the same results with path="" or no path prop at all, but no error message.

@timdorr timdorr closed this as completed Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants