Skip to content

Route parameters inheritance

Compare
Choose a tag to compare
@molefrog molefrog released this 25 Jun 09:46
· 20 commits to v3 since this release

Parameters provided by a Route component or received from calling useParams now also contain values inherited from parent nested routes. See #461 and #409.

Example:

// given the location is "/blog/1/users/4"

<Route path="/:page/:id" nest>
  <Route path="/users/:id">
     {/* calling `useParams()` here will return an object containing `{ page: "blog", id: "4" }`
     {/* note: duplicate keys are overwritten by the inner-most route */}
  </Route>
</Route>