Skip to content
Source
Sign inSign up
TanStack/router

matches types #6666

Openschiller-manuel(GitHub profile, opens in a new tab)wants to merge 6 commits intomain frommatches-typesopened

Showing 14 changed files with 76 additions and 0 deletions (loading 11).

x
0 of 14 viewed, 14 left
64 additions and 0 deletionsexamples/react/large-file-based/src/createRoutes.mjsModified
View file
@@ -2,6 +2,7 @@
import { existsSync } from 'fs'
​
const length = 100
+const nestedDepth = 3
​
const main = async () => {
const absolute = (await readFile('./src/routes/absolute.tsx')).toString()
@@ -34,6 +35,34 @@
await writeFile('./src/routes/(gen)/search/route.tsx', searchRoute)
await writeFile('./src/routes/(gen)/params/route.tsx', paramsRoute)
​
+ const nestedRouteTemplate = (path, label, depthIndex) => {
+ const depthAccess = Array.from({ length: depthIndex + 1 }, (_, index) =>
+ index === 0 ? 'matches[0].routeId' : `matches[${index}]?.routeId`,
+ ).join(' && ')
+​
+ return `import { createFileRoute } from '@tanstack/react-router'
+import * as React from 'react'
+​
+export const Route = createFileRoute('${path}')({
+ component: ${label}Component,
+ head: ({ matches }) => {
+ if (${depthAccess}) {
+ // ...