Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): params.parse should run as minimally as possible #5124

Mergednlynzaad(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/5124/headmerged by nlynzaad(GitHub profile, opens in a new tab)

Showing 3 changed files with 54 additions and 85 deletions (loading 1).

x
0 of 3 viewed, 3 left
26 additions and 34 deletionspackages/react-router/tests/useParams.test.tsxModified
View file
@@ -1,4 +1,4 @@
-import { expect, test } from 'vitest'
+import { expect, test, vi } from 'vitest'
import { act, fireEvent, render, screen } from '@testing-library/react'
import {
Link,
@@ -24,6 +24,7 @@
},
​
+ const mockedfn = vi.fn()
const rootRoute = createRootRoute()
​
const postsRoute = createRoute({
@@ -70,23 +71,19 @@
const postRoute = createRoute({
getParentRoute: () => postCategoryRoute,
path: '$postId',
+ loader: ({ params }) => {
+ return { post: posts.find((post) => post.id === parseInt(params.postId)) }
+ },
params: {
parse: (params) => {
+ mockedfn()