Skip to content
Source
Sign inSign up
TanStack/router

refactor(router-core): reduce buildLocation object allocations #4981

MergedSheraff(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/4981/headmerged by Sheraff(GitHub profile, opens in a new tab)

Showing 3 changed files with 36 additions and 39 deletions (loading 1).

x
0 of 3 viewed, 3 left
12 additions and 12 deletionspackages/react-router/tests/link.test.tsxModified
View file
@@ -4024,8 +4024,8 @@
- const parseParams = vi.fn()
- const stringifyParams = vi.fn()
+ let parseParams: any
+ let stringifyParams: any
const PostComponent = () => {
const params = useParams({ strict: false })
@@ -4036,14 +4036,14 @@
getParentRoute: () => rootRoute,
path: '$postId',
parseParams: (params) => {
- parseParams(params)
+ parseParams = structuredClone(params) // clone object, because source will get mutated
return {
status: 'parsed',
postId: params.postId,
stringifyParams: (params) => {
- stringifyParams(params)
+ stringifyParams = structuredClone(params) // clone object, because source will get mutated