@tanstack/react-router
Version:
Modern and scalable routing for React applications
1 lines • 1.92 kB
Source Map (JSON)
{"version":3,"file":"renderRouteNotFound.cjs","names":[],"sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as React from 'react'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\n/**\n * Renders a not found component for a route when no matching route is found.\n *\n * @param router - The router instance containing the route configuration\n * @param route - The route that triggered the not found state\n * @param data - Additional data to pass to the not found component\n * @returns The rendered not found component or a default fallback component\n */\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent {...data} />\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (!route.options.notFoundComponent) {\n console.warn(\n `Warning: 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 (<p>Not Found</p>)`,\n )\n }\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent {...data} />\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,oBACd,QACA,OACA,MACA;AACA,KAAI,CAAC,MAAM,QAAQ,mBAAmB;AACpC,MAAI,OAAO,QAAQ,yBACjB,QAAO,iBAAA,GAAA,kBAAA,KAAC,OAAO,QAAQ,0BAAhB,EAAyC,GAAI,MAAQ,CAAA;AAG9D,MAAA,QAAA,IAAA,aAA6B;OACvB,CAAC,MAAM,QAAQ,kBACjB,SAAQ,KACN,kEAAkE,MAAM,GAAG,oPAC5E;;AAIL,SAAO,iBAAA,GAAA,kBAAA,KAAC,kBAAA,uBAAD,EAAyB,CAAA;;AAGlC,QAAO,iBAAA,GAAA,kBAAA,KAAC,MAAM,QAAQ,mBAAf,EAAiC,GAAI,MAAQ,CAAA"}