Skip to content

Commit

Permalink
understand lazy route with validateSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
j8seangel committed Jun 6, 2024
1 parent 33befcd commit 65fd665
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/image-labeler/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const IndexLazyRoute = IndexLazyImport.update({
const ProjectProjectIdRoute = ProjectProjectIdImport.update({
path: '/project/$projectId',
getParentRoute: () => rootRoute,
} as any)
} as any).lazy(() =>
import('./routes/project.$projectId.lazy').then((d) => d.Route),
)

// Populate the FileRoutesByPath interface

Expand Down
6 changes: 6 additions & 0 deletions apps/image-labeler/src/routes/project.$projectId.lazy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createLazyFileRoute } from '@tanstack/react-router'
import TasksComponent from '../features/project/Project'

export const Route = createLazyFileRoute('/project/$projectId')({
component: TasksComponent,
})
2 changes: 0 additions & 2 deletions apps/image-labeler/src/routes/project.$projectId.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { createFileRoute } from '@tanstack/react-router'
import TasksComponent from '../features/project/Project'

type ProjectSearchState = {
activeTaskId?: string
}

export const Route = createFileRoute('/project/$projectId')({
component: TasksComponent,
validateSearch: (search: Record<string, unknown>): ProjectSearchState => {
// validate and parse the search params into a typed state
return {
Expand Down

0 comments on commit 65fd665

Please sign in to comment.