Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): support parsed params in matchRoute #7776

OpenLadyBluenotes(GitHub profile, opens in a new tab)wants to merge 29 commits intomain frommatch-route-parsed-paramsopened

Showing 8 changed files with 43 additions and 0 deletions (loading 6).

x
0 of 8 viewed, 8 left
5 additions and 0 deletions.changeset/plenty-jokes-listen.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/router-core': patch
+---
+​
+Fix `matchRoute` to respect parsed path parameters, route precedence, and exact trailing-slash matching.
38 additions and 0 deletionspackages/react-router/tests/Matches.test.tsxModified
View file
@@ -155,6 +155,44 @@
expect(await rendered.findByTestId('root-content')).toBeInTheDocument()
​
+test('useMatchRoute matches typed params from routes with custom parse and stringify functions', async () => {
+ const rootRoute = createRootRoute()
+​
+ function InvoiceComponent() {
+ const matchRoute = useMatchRoute()
+ const match = matchRoute({
+ to: '/invoices/$invoiceId',
+ params: { invoiceId: 123 },
+ })
+​
+ return <div data-testid="match">{JSON.stringify(match)}</div>
+ }
+​