Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(refactor): Split the router out into smaller logical units #10434

Merged
merged 9 commits into from
Apr 15, 2024
46 changes: 46 additions & 0 deletions packages/router/src/Route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react'
import type { ReactElement } from 'react'

import type { PageType } from './page'

export type RenderMode = 'stream' | 'html'

export interface RedirectRouteProps {
redirect: string
path: string
name?: string
}

export interface NotFoundRouteProps {
notfound: boolean
page: PageType
prerender?: boolean
renderMode?: RenderMode
}

export interface RouteProps {
path: string
page: PageType
name: string
prerender?: boolean
renderMode?: RenderMode
whileLoadingPage?: () => ReactElement | null
}

export type InternalRouteProps = Partial<
RouteProps & RedirectRouteProps & NotFoundRouteProps
>

/**
* Route is now a "virtual" component
* it is actually never rendered. All the page loading logic happens in active-route-loader
* and all the validation happens within utility functions called from the Router
*/
export function Route(props: RouteProps): JSX.Element
export function Route(props: RedirectRouteProps): JSX.Element
export function Route(props: NotFoundRouteProps): JSX.Element
export function Route(
_props: RouteProps | RedirectRouteProps | NotFoundRouteProps,
) {
return <></>
}
Loading
Loading