Skip to content

Commit 1093a48

Browse files
committed
feat: tentatively improve performance by caching paths in the router scope
1 parent 2aedbcd commit 1093a48

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/curly-tables-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-router-typesafe': patch
3+
---
4+
5+
`typesafeBrowserRouter`: cache union of all paths in router scope

src/browser-router.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ const joinValidWith =
3737
valid.filter(Boolean).join(separator);
3838

3939
export const typesafeBrowserRouter = <R extends RouteObject>(routes: NarrowArray<R>) => {
40-
function href<P extends ExtractPaths<R>>(
40+
type Paths = ExtractPaths<R>;
41+
42+
function href<P extends Paths>(
4143
params: { path: Extract<P, string> } & PathParams<Flatten<ExtractParams<P>>> & RouteExtraParams,
4244
) {
4345
// applies all params to the path

0 commit comments

Comments
 (0)