UNPKG

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