MCPcopy
hub / github.com/TanStack/router / LazyRoute

Class LazyRoute

packages/solid-router/src/fileRoute.ts:200–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200export class LazyRoute<TRoute extends AnyRoute> {
201 options: {
202 id: string
203 } & LazyRouteOptions
204
205 constructor(
206 opts: {
207 id: string
208 } & LazyRouteOptions,
209 ) {
210 this.options = opts
211 }
212
213 useMatch: UseMatchRoute<TRoute['id']> = (opts) => {
214 return useMatch({
215 select: opts?.select,
216 from: this.options.id,
217 } as any) as any
218 }
219
220 useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {
221 return useRouteContext({ ...(opts as any), from: this.options.id }) as any
222 }
223
224 useSearch: UseSearchRoute<TRoute['id']> = (opts) => {
225 return useSearch({
226 select: opts?.select,
227 from: this.options.id,
228 } as any) as any
229 }
230
231 useParams: UseParamsRoute<TRoute['id']> = (opts) => {
232 return useParams({
233 select: opts?.select,
234 from: this.options.id,
235 } as any) as any
236 }
237
238 useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {
239 return useLoaderDeps({ ...opts, from: this.options.id } as any)
240 }
241
242 useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {
243 return useLoaderData({ ...opts, from: this.options.id } as any)
244 }
245
246 useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {
247 const router = useRouter()
248 return useNavigate({ from: router.routesById[this.options.id].fullPath })
249 }
250}
251
252export function createLazyRoute<
253 TRouter extends AnyRouter = RegisteredRouter,

Callers

nothing calls this directly

Calls 8

useMatchFunction · 0.90
useRouteContextFunction · 0.90
useSearchFunction · 0.90
useParamsFunction · 0.90
useLoaderDepsFunction · 0.90
useLoaderDataFunction · 0.90
useRouterFunction · 0.90
useNavigateFunction · 0.90

Tested by

no test coverage detected