Skip to content

Commit

Permalink
chore(refactor): Split the router out into smaller logical units (#10434
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Tobbe authored Apr 15, 2024
1 parent a6b6136 commit 30f3ecb
Show file tree
Hide file tree
Showing 8 changed files with 669 additions and 524 deletions.
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

0 comments on commit 30f3ecb

Please sign in to comment.