Skip to content

[Bug]: Optional segments break absolute child route paths #9925

@fenok

Description

@fenok

What version of React Router are you using?

6.6.2, also tried 6.7.0-pre.4

Steps to Reproduce

Consider the following routes:

<Routes>
  <Route path="/foo?" element={<Foo />}>
    <Route path="/foo?/bar" element={<Bar />} />
  </Route>
</Routes>

Expected Behavior

<Bar /> is rendered at either /foo/bar or /bar.

Actual Behavior

This fails with the following error: Absolute route path \"/bar\" nested under path \"/foo\" is not valid. An absolute child route path must start with the combined path of all its parent routes.

It looks like the only way to make it work is to switch to relative child route path ("bar").

Context: I build path patterns programmatically, in which case it's easier to use absolute patterns whenever possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting releaseThis issue has been fixed and will be released soonbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions