UNPKG

2.74 kBTypeScriptView Raw
1import * as React from "react";
2import type { TrackedPromise, History, Location, Router, StaticHandlerContext, To, AgnosticRouteObject, AgnosticRouteMatch } from "@remix-run/router";
3import type { Action as NavigationType } from "@remix-run/router";
4export interface RouteObject extends AgnosticRouteObject {
5 children?: RouteObject[];
6 element?: React.ReactNode | null;
7 errorElement?: React.ReactNode | null;
8}
9export interface DataRouteObject extends RouteObject {
10 children?: DataRouteObject[];
11 id: string;
12}
13export interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
14}
15export interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
16}
17export declare const DataStaticRouterContext: React.Context<StaticHandlerContext | null>;
18export interface DataRouterContextObject extends NavigationContextObject {
19 router: Router;
20}
21export declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
22export declare const DataRouterStateContext: React.Context<import("@remix-run/router").RouterState | null>;
23export declare const AwaitContext: React.Context<TrackedPromise | null>;
24export declare type RelativeRoutingType = "route" | "path";
25export interface NavigateOptions {
26 replace?: boolean;
27 state?: any;
28 preventScrollReset?: boolean;
29 relative?: RelativeRoutingType;
30}
31/**
32 * A Navigator is a "location changer"; it's how you get to different locations.
33 *
34 * Every history instance conforms to the Navigator interface, but the
35 * distinction is useful primarily when it comes to the low-level <Router> API
36 * where both the location and a navigator must be provided separately in order
37 * to avoid "tearing" that may occur in a suspense-enabled app if the action
38 * and/or location were to be read directly from the history instance.
39 */
40export interface Navigator {
41 createHref: History["createHref"];
42 go: History["go"];
43 push(to: To, state?: any, opts?: NavigateOptions): void;
44 replace(to: To, state?: any, opts?: NavigateOptions): void;
45}
46interface NavigationContextObject {
47 basename: string;
48 navigator: Navigator;
49 static: boolean;
50}
51export declare const NavigationContext: React.Context<NavigationContextObject>;
52interface LocationContextObject {
53 location: Location;
54 navigationType: NavigationType;
55}
56export declare const LocationContext: React.Context<LocationContextObject>;
57export interface RouteContextObject {
58 outlet: React.ReactElement | null;
59 matches: RouteMatch[];
60}
61export declare const RouteContext: React.Context<RouteContextObject>;
62export declare const RouteErrorContext: React.Context<any>;
63export {};