Open History to see the last commit
1import * as React from 'react'
2import warning from 'tiny-warning'
3import { DefaultGlobalNotFound } from './not-found'
4import type { AnyRoute, AnyRouter } from '@tanstack/router-core'
5β
6export function renderRouteNotFound(
7 router: AnyRouter,
8 route: AnyRoute,
9 data: any,
10) {
11 if (!route.options.notFoundComponent) {
12 if (router.options.defaultNotFoundComponent) {
13 return <router.options.defaultNotFoundComponent data={data} />
14 }
15β
16 if (process.env.NODE_ENV === 'development') {
17 warning(
18 route.options.notFoundComponent,
19 `A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,
20 )
21 }
22β
23 return <DefaultGlobalNotFound />
24 }
25β
26 return <route.options.notFoundComponent data={data} />
27}