Complete to "Client Side Routing"

This commit is contained in:
2025-03-30 21:13:08 +02:00
parent 792bb27d06
commit 3324a15cee
3 changed files with 134 additions and 7 deletions

View File

@@ -12,6 +12,7 @@
import { Route as rootRoute } from './routes/__root'
import { Route as IndexImport } from './routes/index'
import { Route as ContactsContractIdImport } from './routes/contacts.$contractId'
// Create/Update Routes
@@ -21,6 +22,12 @@ const IndexRoute = IndexImport.update({
getParentRoute: () => rootRoute,
} as any)
const ContactsContractIdRoute = ContactsContractIdImport.update({
id: '/contacts/$contractId',
path: '/contacts/$contractId',
getParentRoute: () => rootRoute,
} as any)
// Populate the FileRoutesByPath interface
declare module '@tanstack/react-router' {
@@ -32,6 +39,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof IndexImport
parentRoute: typeof rootRoute
}
'/contacts/$contractId': {
id: '/contacts/$contractId'
path: '/contacts/$contractId'
fullPath: '/contacts/$contractId'
preLoaderRoute: typeof ContactsContractIdImport
parentRoute: typeof rootRoute
}
}
}
@@ -39,32 +53,37 @@ declare module '@tanstack/react-router' {
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/contacts/$contractId': typeof ContactsContractIdRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/contacts/$contractId': typeof ContactsContractIdRoute
}
export interface FileRoutesById {
__root__: typeof rootRoute
'/': typeof IndexRoute
'/contacts/$contractId': typeof ContactsContractIdRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/'
fullPaths: '/' | '/contacts/$contractId'
fileRoutesByTo: FileRoutesByTo
to: '/'
id: '__root__' | '/'
to: '/' | '/contacts/$contractId'
id: '__root__' | '/' | '/contacts/$contractId'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
ContactsContractIdRoute: typeof ContactsContractIdRoute
}
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
ContactsContractIdRoute: ContactsContractIdRoute,
}
export const routeTree = rootRoute
@@ -77,11 +96,15 @@ export const routeTree = rootRoute
"__root__": {
"filePath": "__root.tsx",
"children": [
"/"
"/",
"/contacts/$contractId"
]
},
"/": {
"filePath": "index.tsx"
},
"/contacts/$contractId": {
"filePath": "contacts.$contractId.tsx"
}
}
}