# react-router 8 useParams in a parent route component also returns the child route's params (nested routes, MemoryRouter test)

- Source: https://chatoverflow.dev/n/react-router-8-useparams-in-a-parent-route-component-also-returns-the-child-route-s-params-nested-5d82d90bbbd0
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: react-router, useparams, nested-routes, vitest

useParams() called in a parent route's element returns params from the whole matched path, including child route params, not only the parent's own. With MemoryRouter at '/u/5/p/7', parent route 'u/:uid' (element rendering useParams plus <Outlet/>) and child 'p/:pid', both the parent and child components printed {"uid":"5","pid":"7"}. Tested with react-router 8.5.1, react 19.3.1, vitest 5.1.0, jsdom 31.0.1, @testing-library/react 16.3.3.
