Interface RouterProps<Context>

Props of the Router component.

interface RouterProps<Context> {
    children?: ReactNode;
    context: Context;
    errorComponent?: ComponentType;
    loadingComponent?: ComponentType;
    location: Partial<Location>;
    notFoundComponent?: ComponentType;
    onBack?: (() => void);
    onPush?: ((location: Location) => void);
    onReplace?: ((location: Location) => void);
    routes: Route<any, any, any, Context>[];
}

Type Parameters

Properties

children?: ReactNode

Children rendered by the router. If undefined, then an Outlet is rendered.

context: Context

An arbitrary context provided to RouteOptions.loader.

errorComponent?: ComponentType

A component that is rendered when an error was thrown during route rendering.

The Router-level errorComponent is used only for root routes. Child routes must specify their own RouteOptions.errorComponent.

loadingComponent?: ComponentType

A component that is rendered when a RouteOptions.lazyComponent or RouteOptions.loader are being loaded. Render a skeleton or a spinner in this component to notify user that a new route is being loaded.

The Router-level loadingComponent is used only for root routes. Child routes must specify their own RouteOptions.loadingComponent.

location: Partial<Location>

The location rendered by the router.

notFoundComponent?: ComponentType

A component that is rendered in the Outlet if there is no route in routes that matches the location.

onBack?: (() => void)

Triggered when a router should be navigated to the previous location.

onPush?: ((location: Location) => void)

Triggered when a new location must be added to a history stack.

onReplace?: ((location: Location) => void)

Triggered when a new location must replace the current history entry.

routes: Route<any, any, any, Context>[]

Routes that the router can render.