mirror of
https://github.com/TanStack/router.git
synced 2026-11-16 19:38:07 +00:00
#5020 highlighted an issue where when using useParams in parent route (that has its own path param) with child routes that also use path params this can cause excessive re-rendering of the parent route when the params for the child routes changes. The root cause for this is that the child params are available to the parent route, even when strict=false was not specified and this also does not match to the types that is being returned in this case. This can be worked around by using select inside the useParams hook/function but results in unnecessary boilerplate. This PR attempts to resolve the issue by dealing with the two distinct cases, one where we are only concerned about the path params of the current route and prior routes (strict=true/undefined) and the second where we want access in the parent route to the path params of the child routes (strict=false). In the strict case we use the match id to return the params of the specific match, which is constant and results in stable rendering, while in the strict=false case we fallback to the initial implementation of returning params from the useMatch result which can be variable and requires re-rendering to be done. Changes were done on useParams for both react and solid, in solid's case this wasn't causing re-renders but did return unexpected child params, the change for solid is more toward keeping the API and expected outputs consistent between the two frameworks. existing unit tests for react was updated and e2e tests for both frameworks was added to ensure rendering and results match the expected. A separate merge has been prepared for Alpha and will be merged on signoff of this one. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added nested named-parameter routes (three-level: foo → bar → baz) in example apps with nested navigation, outlets, links and render-count displays. - Added a small render-counter component to visualize component re-renders. - **Bug Fixes** - Improved params selection to respect strict vs non-strict modes, reducing excess renders and producing stable param values. - **Tests** - Added E2E tests for React and Solid examples covering param navigation and render-counts; expanded router unit tests for nested-route stability and remount behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
History
|
|
|---|---|---|
| .. | ||
| src | ||
| tests | ||
| .gitignore | ||
| index.html | ||
| package.json | ||
| playwright.config.ts | ||
| postcss.config.mjs | ||
| tailwind.config.mjs | ||
| tsconfig.json | ||
| vite.config.js | ||