* What route properties a loader resolves to render: the reference for its * page, `Outlet` for React Router's, null for none, undefined for properties * this does not read.
(value: Loaded | null, elementTag: (jsx: string) => string | undefined)
| 1570 | * this does not read. |
| 1571 | */ |
| 1572 | function routeRender(value: Loaded | null, elementTag: (jsx: string) => string | undefined): string | null | undefined { |
| 1573 | if (value?.kind === 'module') return LAZY_ROUTE_PREFIX + value.spec; |
| 1574 | if (value?.kind !== 'object') return undefined; |
| 1575 | const { props, spreads } = objectEntries(value.text); |
| 1576 | const component = props.get('Component'); |
| 1577 | const element = props.get('element'); |
| 1578 | const shown = component ?? element; |
| 1579 | if (shown !== undefined) { |
| 1580 | const held = component !== undefined ? valueOf(component, value.scope) : null; |
| 1581 | const named = pageReference(held); |
| 1582 | if (named) return named; |
| 1583 | // The one export the loader imported that it shows, past a guard of the |
| 1584 | // route file's own: `<AgeGate><FireworksPage /></AgeGate>`, `() => |
| 1585 | // <PrivateRoute component={<Favorites />} />`, `withAuth(Page)`. |
| 1586 | const loaded = loadedExports(shown, value.scope); |
| 1587 | if (loaded.length === 1) return pageReference(loaded[0]!); |
| 1588 | const tag = component === undefined && loaded.length === 0 ? elementTag(element!) : undefined; |
| 1589 | // `Component: Outlet`, `element: <Outlet />`: the routes inside render in its place. |
| 1590 | if ((held?.kind === 'name' && held.name === OUTLET) || tag === OUTLET) return OUTLET; |
| 1591 | return tag ? pageReference(nameValue(tag, value.scope)) : undefined; |
| 1592 | } |
| 1593 | // `{ ...module }`: the module's exports are the route's properties. |
| 1594 | if (spreads.length === 0) return null; |
| 1595 | const spread = spreads.length === 1 ? valueOf(spreads[0]!, value.scope) : null; |
| 1596 | return spread?.kind === 'module' ? LAZY_ROUTE_PREFIX + spread.spec : undefined; |
| 1597 | } |
| 1598 | |
| 1599 | /** |
| 1600 | * React Router 7's object of lazy properties, `lazy: { loader: …, Component: |
no test coverage detected