react-router 0.0.0-experimental-818f8e08d → 0.0.0-experimental-e56aa53bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -19
- package/dist/development/{chunk-4O47XL4L.mjs → chunk-RMWJZNG5.mjs} +1045 -354
- package/dist/development/data-CQbyyGzl.d.mts +11 -0
- package/dist/development/data-CQbyyGzl.d.ts +11 -0
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +2 -1
- package/dist/development/dom-export.js +6130 -35
- package/dist/development/dom-export.mjs +3 -6
- package/dist/development/fog-of-war-C5L_Yd5M.d.mts +1778 -0
- package/dist/{production/fog-of-war-B1MWugqW.d.mts → development/fog-of-war-DrUCUQQ-.d.ts} +170 -138
- package/dist/development/index.d.mts +68 -10
- package/dist/development/index.d.ts +207 -1889
- package/dist/development/index.js +1052 -352
- package/dist/development/index.mjs +19 -2
- package/dist/development/lib/types/route-module.d.mts +2 -1
- package/dist/development/lib/types/route-module.d.ts +2 -1
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/{production/route-data-BvrN3Sw4.d.mts → development/route-data-BIYebJr3.d.mts} +12 -12
- package/dist/{production/route-data-fNWkI-4T.d.ts → development/route-data-BIYebJr3.d.ts} +12 -12
- package/dist/development/rsc-export.d.mts +1788 -0
- package/dist/development/rsc-export.d.ts +1788 -0
- package/dist/development/rsc-export.js +2778 -0
- package/dist/development/rsc-export.mjs +2743 -0
- package/dist/production/{chunk-P2C2EGLF.mjs → chunk-BXBFRMFA.mjs} +1045 -354
- package/dist/production/data-CQbyyGzl.d.mts +11 -0
- package/dist/production/data-CQbyyGzl.d.ts +11 -0
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +2 -1
- package/dist/production/dom-export.js +6130 -35
- package/dist/production/dom-export.mjs +3 -6
- package/dist/production/fog-of-war-C5L_Yd5M.d.mts +1778 -0
- package/dist/{development/fog-of-war-B1MWugqW.d.mts → production/fog-of-war-DrUCUQQ-.d.ts} +170 -138
- package/dist/production/index.d.mts +68 -10
- package/dist/production/index.d.ts +207 -1889
- package/dist/production/index.js +1052 -352
- package/dist/production/index.mjs +19 -2
- package/dist/production/lib/types/route-module.d.mts +2 -1
- package/dist/production/lib/types/route-module.d.ts +2 -1
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/{development/route-data-BvrN3Sw4.d.mts → production/route-data-BIYebJr3.d.mts} +12 -12
- package/dist/{development/route-data-fNWkI-4T.d.ts → production/route-data-BIYebJr3.d.ts} +12 -12
- package/dist/production/rsc-export.d.mts +1788 -0
- package/dist/production/rsc-export.d.ts +1788 -0
- package/dist/production/rsc-export.js +2778 -0
- package/dist/production/rsc-export.mjs +2743 -0
- package/package.json +33 -2
|
@@ -1,420 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { a as Router, b as RouteModules, D as DataStrategyFunction, c as RouteManifest, S as ServerRouteModule, M as MiddlewareEnabled, u as unstable_RouterContextProvider, L as LoaderFunctionArgs, A as ActionFunctionArgs, T as To, d as RelativeRoutingType, e as Location, f as Action, P as ParamParseKey, g as Path, h as PathPattern, i as PathMatch, N as NavigateOptions, j as Params$1, k as RouteObject, l as Navigation, m as RevalidationState, U as UIMatch, n as SerializeFrom, B as BlockerFunction, o as Blocker, p as StaticHandlerContext, q as StaticHandler, F as FutureConfig$1, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, r as unstable_InitialContext, s as IndexRouteObject, t as LoaderFunction, v as ActionFunction, w as MetaFunction, x as LinksFunction, y as NonIndexRouteObject, E as Equal, z as RouterState, G as DataRouteObject, J as ClientLoaderFunction } from './route-data-BIYebJr3.js';
|
|
2
|
+
export { aw as ClientActionFunction, ax as ClientActionFunctionArgs, ay as ClientLoaderFunctionArgs, ar as DataRouteMatch, Z as DataStrategyFunctionArgs, _ as DataStrategyMatch, $ as DataStrategyResult, a1 as ErrorResponse, Q as Fetcher, a2 as FormEncType, a3 as FormMethod, aG as Future, K as GetScrollPositionFunction, O as GetScrollRestorationKeyFunction, a4 as HTMLFormMethod, az as HeadersArgs, aA as HeadersFunction, aE as HtmlLinkDescriptor, ah as IDLE_BLOCKER, ag as IDLE_FETCHER, af as IDLE_NAVIGATION, a5 as LazyRouteFunction, aF as LinkDescriptor, aB as MetaArgs, aC as MetaDescriptor, V as NavigationStates, as as Navigator, aD as PageLinkDescriptor, at as PatchRoutesOnNavigationFunction, au as PatchRoutesOnNavigationFunctionArgs, a7 as PathParam, a8 as RedirectFunction, av as RouteMatch, Y as RouterFetchOptions, R as RouterInit, X as RouterNavigateOptions, W as RouterSubscriber, aa as ShouldRevalidateFunction, ab as ShouldRevalidateFunctionArgs, aM as UNSAFE_DataRouterContext, aN as UNSAFE_DataRouterStateContext, a0 as UNSAFE_DataWithResponseInit, aL as UNSAFE_ErrorResponseImpl, aO as UNSAFE_FetchersContext, aP as UNSAFE_LocationContext, aQ as UNSAFE_NavigationContext, aR as UNSAFE_RouteContext, aS as UNSAFE_ViewTransitionContext, aI as UNSAFE_createBrowserHistory, aK as UNSAFE_createRouter, aJ as UNSAFE_invariant, ad as createPath, ai as data, aj as generatePath, ak as isRouteErrorResponse, al as matchPath, am as matchRoutes, ae as parsePath, an as redirect, ao as redirectDocument, ap as replace, aq as resolvePath, a6 as unstable_MiddlewareFunction, a9 as unstable_RouterContext, aH as unstable_SerializesTo, ac as unstable_createContext } from './route-data-BIYebJr3.js';
|
|
3
|
+
import { A as AssetsManifest, a as Route, F as FutureConfig, E as EntryContext, C as CriticalCss, S as ServerPayload } from './fog-of-war-DrUCUQQ-.js';
|
|
4
|
+
export { g as Await, b as AwaitProps, U as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, aj as DecodeServerResponseFunction, ak as EncodeActionFunction, w as FetcherFormProps, J as FetcherSubmitFunction, a8 as FetcherSubmitOptions, K as FetcherWithComponents, Z as Form, x as FormProps, V as HashRouter, H as HashRouterProps, s as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, W as Link, t as LinkProps, af as Links, h as MemoryRouter, M as MemoryRouterOpts, c as MemoryRouterProps, ae as Meta, Y as NavLink, u as NavLinkProps, v as NavLinkRenderProps, i as Navigate, N as NavigateProps, j as Outlet, O as OutletProps, a9 as ParamKeyValuePair, P as PathRouteProps, ah as PrefetchPageLinks, am as RSCHydratedRouter, k as Route, d as RouteProps, l as Router, e as RouterProps, m as RouterProvider, R as RouterProviderProps, n as Routes, f as RoutesProps, ag as Scripts, ai as ScriptsProps, _ as ScrollRestoration, y as ScrollRestorationProps, z as SetURLSearchParams, G as SubmitFunction, aa as SubmitOptions, ac as SubmitTarget, at as UNSAFE_FrameworkContext, aq as UNSAFE_WithErrorBoundaryProps, ap as UNSAFE_WithHydrateFallbackProps, ao as UNSAFE_WithRouteComponentProps, aw as UNSAFE_createClientRoutes, ax as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, au as UNSAFE_getPatchRoutesOnNavigationFunction, ar as UNSAFE_hydrationRouteProperties, as as UNSAFE_mapRouteProperties, ay as UNSAFE_shouldHydrateRouteLoader, av as UNSAFE_useFogOFWarDiscovery, az as UNSAFE_useScrollRestoration, ab as URLSearchParamsInit, Q as createBrowserRouter, al as createCallServer, T as createHashRouter, o as createMemoryRouter, p as createRoutesFromChildren, q as createRoutesFromElements, ad as createSearchParams, an as getServerStream, r as renderMatches, X as unstable_HistoryRouter, a6 as unstable_usePrompt, a5 as useBeforeUnload, a3 as useFetcher, a4 as useFetchers, a2 as useFormAction, $ as useLinkClickHandler, a0 as useSearchParams, a1 as useSubmit, a7 as useViewTransitionState } from './fog-of-war-DrUCUQQ-.js';
|
|
3
5
|
import * as React from 'react';
|
|
4
6
|
import { ReactElement } from 'react';
|
|
5
7
|
import { ParseOptions, SerializeOptions } from 'cookie';
|
|
6
8
|
export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
|
|
9
|
+
import { A as AppLoadContext } from './data-CQbyyGzl.js';
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
declare const hydrationRouteProperties: (keyof RouteObject)[];
|
|
15
|
-
interface MemoryRouterOpts {
|
|
16
|
-
/**
|
|
17
|
-
* Basename path for the application.
|
|
18
|
-
*/
|
|
19
|
-
basename?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Function to provide the initial context values for all client side navigations/fetches
|
|
22
|
-
*/
|
|
23
|
-
unstable_getContext?: RouterInit["unstable_getContext"];
|
|
24
|
-
/**
|
|
25
|
-
* Future flags to enable for the router.
|
|
26
|
-
*/
|
|
27
|
-
future?: Partial<FutureConfig$1>;
|
|
28
|
-
/**
|
|
29
|
-
* Hydration data to initialize the router with if you have already performed
|
|
30
|
-
* data loading on the server.
|
|
31
|
-
*/
|
|
32
|
-
hydrationData?: HydrationState;
|
|
33
|
-
/**
|
|
34
|
-
* Initial entires in the in-memory history stack
|
|
35
|
-
*/
|
|
36
|
-
initialEntries?: InitialEntry[];
|
|
37
|
-
/**
|
|
38
|
-
* Index of `initialEntries` the application should initialize to
|
|
39
|
-
*/
|
|
40
|
-
initialIndex?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Override the default data strategy of loading in parallel.
|
|
43
|
-
* Only intended for advanced usage.
|
|
44
|
-
*/
|
|
45
|
-
dataStrategy?: DataStrategyFunction;
|
|
46
|
-
/**
|
|
47
|
-
* Lazily define portions of the route tree on navigations.
|
|
48
|
-
*/
|
|
49
|
-
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Create a new data router that manages the application path using an in-memory
|
|
53
|
-
* history stack. Useful for non-browser environments without a DOM API.
|
|
54
|
-
*
|
|
55
|
-
* @category Data Routers
|
|
56
|
-
*/
|
|
57
|
-
declare function createMemoryRouter(
|
|
58
|
-
/**
|
|
59
|
-
* Application routes
|
|
60
|
-
*/
|
|
61
|
-
routes: RouteObject[],
|
|
62
|
-
/**
|
|
63
|
-
* Router options
|
|
64
|
-
*/
|
|
65
|
-
opts?: MemoryRouterOpts): Router$1;
|
|
66
|
-
interface RouterProviderProps {
|
|
67
|
-
router: Router$1;
|
|
68
|
-
flushSync?: (fn: () => unknown) => undefined;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Given a Remix Router instance, render the appropriate UI
|
|
72
|
-
*/
|
|
73
|
-
declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
|
|
74
|
-
/**
|
|
75
|
-
* @category Types
|
|
76
|
-
*/
|
|
77
|
-
interface MemoryRouterProps {
|
|
78
|
-
basename?: string;
|
|
79
|
-
children?: React.ReactNode;
|
|
80
|
-
initialEntries?: InitialEntry[];
|
|
81
|
-
initialIndex?: number;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* A `<Router>` that stores all entries in memory.
|
|
85
|
-
*
|
|
86
|
-
* @category Component Routers
|
|
87
|
-
*/
|
|
88
|
-
declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
|
|
89
|
-
/**
|
|
90
|
-
* @category Types
|
|
91
|
-
*/
|
|
92
|
-
interface NavigateProps {
|
|
93
|
-
to: To;
|
|
94
|
-
replace?: boolean;
|
|
95
|
-
state?: any;
|
|
96
|
-
relative?: RelativeRoutingType;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* A component-based version of {@link useNavigate} to use in a [`React.Component
|
|
100
|
-
* Class`](https://reactjs.org/docs/react-component.html) where hooks are not
|
|
101
|
-
* able to be used.
|
|
102
|
-
*
|
|
103
|
-
* It's recommended to avoid using this component in favor of {@link useNavigate}
|
|
104
|
-
*
|
|
105
|
-
* @category Components
|
|
106
|
-
*/
|
|
107
|
-
declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
|
|
108
|
-
/**
|
|
109
|
-
* @category Types
|
|
110
|
-
*/
|
|
111
|
-
interface OutletProps {
|
|
112
|
-
/**
|
|
113
|
-
Provides a context value to the element tree below the outlet. Use when the parent route needs to provide values to child routes.
|
|
114
|
-
|
|
115
|
-
```tsx
|
|
116
|
-
<Outlet context={myContextValue} />
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Access the context with {@link useOutletContext}.
|
|
120
|
-
*/
|
|
121
|
-
context?: unknown;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
Renders the matching child route of a parent route or nothing if no child route matches.
|
|
125
|
-
|
|
126
|
-
```tsx
|
|
127
|
-
import { Outlet } from "react-router"
|
|
128
|
-
|
|
129
|
-
export default function SomeParent() {
|
|
130
|
-
return (
|
|
131
|
-
<div>
|
|
132
|
-
<h1>Parent Content</h1>
|
|
133
|
-
<Outlet />
|
|
134
|
-
</div>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
@category Components
|
|
140
|
-
*/
|
|
141
|
-
declare function Outlet(props: OutletProps): React.ReactElement | null;
|
|
142
|
-
/**
|
|
143
|
-
* @category Types
|
|
144
|
-
*/
|
|
145
|
-
interface PathRouteProps {
|
|
146
|
-
caseSensitive?: NonIndexRouteObject["caseSensitive"];
|
|
147
|
-
path?: NonIndexRouteObject["path"];
|
|
148
|
-
id?: NonIndexRouteObject["id"];
|
|
149
|
-
lazy?: LazyRouteFunction<NonIndexRouteObject>;
|
|
150
|
-
loader?: NonIndexRouteObject["loader"];
|
|
151
|
-
action?: NonIndexRouteObject["action"];
|
|
152
|
-
hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
|
|
153
|
-
shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
|
|
154
|
-
handle?: NonIndexRouteObject["handle"];
|
|
155
|
-
index?: false;
|
|
156
|
-
children?: React.ReactNode;
|
|
157
|
-
element?: React.ReactNode | null;
|
|
158
|
-
hydrateFallbackElement?: React.ReactNode | null;
|
|
159
|
-
errorElement?: React.ReactNode | null;
|
|
160
|
-
Component?: React.ComponentType | null;
|
|
161
|
-
HydrateFallback?: React.ComponentType | null;
|
|
162
|
-
ErrorBoundary?: React.ComponentType | null;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* @category Types
|
|
166
|
-
*/
|
|
167
|
-
interface LayoutRouteProps extends PathRouteProps {
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* @category Types
|
|
171
|
-
*/
|
|
172
|
-
interface IndexRouteProps {
|
|
173
|
-
caseSensitive?: IndexRouteObject["caseSensitive"];
|
|
174
|
-
path?: IndexRouteObject["path"];
|
|
175
|
-
id?: IndexRouteObject["id"];
|
|
176
|
-
lazy?: LazyRouteFunction<IndexRouteObject>;
|
|
177
|
-
loader?: IndexRouteObject["loader"];
|
|
178
|
-
action?: IndexRouteObject["action"];
|
|
179
|
-
hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
|
|
180
|
-
shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
|
|
181
|
-
handle?: IndexRouteObject["handle"];
|
|
182
|
-
index: true;
|
|
183
|
-
children?: undefined;
|
|
184
|
-
element?: React.ReactNode | null;
|
|
185
|
-
hydrateFallbackElement?: React.ReactNode | null;
|
|
186
|
-
errorElement?: React.ReactNode | null;
|
|
187
|
-
Component?: React.ComponentType | null;
|
|
188
|
-
HydrateFallback?: React.ComponentType | null;
|
|
189
|
-
ErrorBoundary?: React.ComponentType | null;
|
|
190
|
-
}
|
|
191
|
-
type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
|
|
192
|
-
/**
|
|
193
|
-
* Configures an element to render when a pattern matches the current location.
|
|
194
|
-
* It must be rendered within a {@link Routes} element. Note that these routes
|
|
195
|
-
* do not participate in data loading, actions, code splitting, or any other
|
|
196
|
-
* route module features.
|
|
197
|
-
*
|
|
198
|
-
* @category Components
|
|
199
|
-
*/
|
|
200
|
-
declare function Route$1(_props: RouteProps): React.ReactElement | null;
|
|
201
|
-
/**
|
|
202
|
-
* @category Types
|
|
203
|
-
*/
|
|
204
|
-
interface RouterProps {
|
|
205
|
-
basename?: string;
|
|
206
|
-
children?: React.ReactNode;
|
|
207
|
-
location: Partial<Location> | string;
|
|
208
|
-
navigationType?: Action;
|
|
209
|
-
navigator: Navigator;
|
|
210
|
-
static?: boolean;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Provides location context for the rest of the app.
|
|
214
|
-
*
|
|
215
|
-
* Note: You usually won't render a `<Router>` directly. Instead, you'll render a
|
|
216
|
-
* router that is more specific to your environment such as a `<BrowserRouter>`
|
|
217
|
-
* in web browsers or a `<StaticRouter>` for server rendering.
|
|
218
|
-
*
|
|
219
|
-
* @category Components
|
|
220
|
-
*/
|
|
221
|
-
declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
|
|
222
|
-
/**
|
|
223
|
-
* @category Types
|
|
224
|
-
*/
|
|
225
|
-
interface RoutesProps {
|
|
226
|
-
/**
|
|
227
|
-
* Nested {@link Route} elements
|
|
228
|
-
*/
|
|
229
|
-
children?: React.ReactNode;
|
|
230
|
-
/**
|
|
231
|
-
* The location to match against. Defaults to the current location.
|
|
232
|
-
*/
|
|
233
|
-
location?: Partial<Location> | string;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
Renders a branch of {@link Route | `<Routes>`} that best matches the current
|
|
237
|
-
location. Note that these routes do not participate in data loading, actions,
|
|
238
|
-
code splitting, or any other route module features.
|
|
239
|
-
|
|
240
|
-
```tsx
|
|
241
|
-
import { Routes, Route } from "react-router"
|
|
242
|
-
|
|
243
|
-
<Routes>
|
|
244
|
-
<Route index element={<StepOne />} />
|
|
245
|
-
<Route path="step-2" element={<StepTwo />} />
|
|
246
|
-
<Route path="step-3" element={<StepThree />}>
|
|
247
|
-
</Routes>
|
|
248
|
-
```
|
|
11
|
+
declare const SingleFetchRedirectSymbol: unique symbol;
|
|
12
|
+
declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
|
|
13
|
+
declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
|
|
14
|
+
done: Promise<undefined>;
|
|
15
|
+
value: unknown;
|
|
16
|
+
}>;
|
|
249
17
|
|
|
250
|
-
@category Components
|
|
251
|
-
*/
|
|
252
|
-
declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
|
|
253
|
-
interface AwaitResolveRenderFunction<Resolve = any> {
|
|
254
|
-
(data: Awaited<Resolve>): React.ReactNode;
|
|
255
|
-
}
|
|
256
18
|
/**
|
|
257
|
-
*
|
|
19
|
+
* The mode to use when running the server.
|
|
258
20
|
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
```tsx [2]
|
|
264
|
-
<Await resolve={reviewsPromise}>
|
|
265
|
-
{(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
266
|
-
</Await>
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
When using React elements, {@link useAsyncValue} will provide the
|
|
270
|
-
resolved value:
|
|
271
|
-
|
|
272
|
-
```tsx [2]
|
|
273
|
-
<Await resolve={reviewsPromise}>
|
|
274
|
-
<Reviews />
|
|
275
|
-
</Await>
|
|
276
|
-
|
|
277
|
-
function Reviews() {
|
|
278
|
-
const resolvedReviews = useAsyncValue()
|
|
279
|
-
return <div>...</div>
|
|
280
|
-
}
|
|
281
|
-
```
|
|
282
|
-
*/
|
|
283
|
-
children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
|
|
284
|
-
/**
|
|
285
|
-
The error element renders instead of the children when the promise rejects.
|
|
286
|
-
|
|
287
|
-
```tsx
|
|
288
|
-
<Await
|
|
289
|
-
errorElement={<div>Oops</div>}
|
|
290
|
-
resolve={reviewsPromise}
|
|
291
|
-
>
|
|
292
|
-
<Reviews />
|
|
293
|
-
</Await>
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
To provide a more contextual error, you can use the {@link useAsyncError} in a
|
|
297
|
-
child component
|
|
298
|
-
|
|
299
|
-
```tsx
|
|
300
|
-
<Await
|
|
301
|
-
errorElement={<ReviewsError />}
|
|
302
|
-
resolve={reviewsPromise}
|
|
303
|
-
>
|
|
304
|
-
<Reviews />
|
|
305
|
-
</Await>
|
|
306
|
-
|
|
307
|
-
function ReviewsError() {
|
|
308
|
-
const error = useAsyncError()
|
|
309
|
-
return <div>Error loading reviews: {error.message}</div>
|
|
310
|
-
}
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
If you do not provide an errorElement, the rejected value will bubble up to
|
|
314
|
-
the nearest route-level {@link NonIndexRouteObject#ErrorBoundary | ErrorBoundary} and be accessible
|
|
315
|
-
via {@link useRouteError} hook.
|
|
316
|
-
*/
|
|
317
|
-
errorElement?: React.ReactNode;
|
|
318
|
-
/**
|
|
319
|
-
Takes a promise returned from a {@link LoaderFunction | loader} value to be resolved and rendered.
|
|
320
|
-
|
|
321
|
-
```jsx
|
|
322
|
-
import { useLoaderData, Await } from "react-router"
|
|
323
|
-
|
|
324
|
-
export async function loader() {
|
|
325
|
-
let reviews = getReviews() // not awaited
|
|
326
|
-
let book = await getBook()
|
|
327
|
-
return {
|
|
328
|
-
book,
|
|
329
|
-
reviews, // this is a promise
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export default function Book() {
|
|
334
|
-
const {
|
|
335
|
-
book,
|
|
336
|
-
reviews, // this is the same promise
|
|
337
|
-
} = useLoaderData()
|
|
338
|
-
|
|
339
|
-
return (
|
|
340
|
-
<div>
|
|
341
|
-
<h1>{book.title}</h1>
|
|
342
|
-
<p>{book.description}</p>
|
|
343
|
-
<React.Suspense fallback={<ReviewsSkeleton />}>
|
|
344
|
-
<Await
|
|
345
|
-
// and is the promise we pass to Await
|
|
346
|
-
resolve={reviews}
|
|
347
|
-
>
|
|
348
|
-
<Reviews />
|
|
349
|
-
</Await>
|
|
350
|
-
</React.Suspense>
|
|
351
|
-
</div>
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
```
|
|
355
|
-
*/
|
|
356
|
-
resolve: Resolve;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
Used to render promise values with automatic error handling.
|
|
360
|
-
|
|
361
|
-
```tsx
|
|
362
|
-
import { Await, useLoaderData } from "react-router";
|
|
363
|
-
|
|
364
|
-
export function loader() {
|
|
365
|
-
// not awaited
|
|
366
|
-
const reviews = getReviews()
|
|
367
|
-
// awaited (blocks the transition)
|
|
368
|
-
const book = await fetch("/api/book").then((res) => res.json())
|
|
369
|
-
return { book, reviews }
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
function Book() {
|
|
373
|
-
const { book, reviews } = useLoaderData();
|
|
374
|
-
return (
|
|
375
|
-
<div>
|
|
376
|
-
<h1>{book.title}</h1>
|
|
377
|
-
<p>{book.description}</p>
|
|
378
|
-
<React.Suspense fallback={<ReviewsSkeleton />}>
|
|
379
|
-
<Await
|
|
380
|
-
resolve={reviews}
|
|
381
|
-
errorElement={
|
|
382
|
-
<div>Could not load reviews 😬</div>
|
|
383
|
-
}
|
|
384
|
-
children={(resolvedReviews) => (
|
|
385
|
-
<Reviews items={resolvedReviews} />
|
|
386
|
-
)}
|
|
387
|
-
/>
|
|
388
|
-
</React.Suspense>
|
|
389
|
-
</div>
|
|
390
|
-
);
|
|
21
|
+
declare enum ServerMode {
|
|
22
|
+
Development = "development",
|
|
23
|
+
Production = "production",
|
|
24
|
+
Test = "test"
|
|
391
25
|
}
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
**Note:** `<Await>` expects to be rendered inside of a `<React.Suspense>`
|
|
395
|
-
|
|
396
|
-
@category Components
|
|
397
|
-
|
|
398
|
-
*/
|
|
399
|
-
declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
|
|
400
|
-
/**
|
|
401
|
-
* Creates a route config from a React "children" object, which is usually
|
|
402
|
-
* either a `<Route>` element or an array of them. Used internally by
|
|
403
|
-
* `<Routes>` to create a route config from its children.
|
|
404
|
-
*
|
|
405
|
-
* @category Utils
|
|
406
|
-
*/
|
|
407
|
-
declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
|
|
408
|
-
/**
|
|
409
|
-
* Create route objects from JSX elements instead of arrays of objects
|
|
410
|
-
*/
|
|
411
|
-
declare let createRoutesFromElements: typeof createRoutesFromChildren;
|
|
412
|
-
/**
|
|
413
|
-
* Renders the result of `matchRoutes()` into a React element.
|
|
414
|
-
*
|
|
415
|
-
* @category Utils
|
|
416
|
-
*/
|
|
417
|
-
declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
|
|
418
26
|
|
|
419
27
|
type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
|
|
420
28
|
interface ServerRoute extends Route {
|
|
@@ -445,10 +53,6 @@ interface ServerBuild {
|
|
|
445
53
|
*/
|
|
446
54
|
isSpaMode: boolean;
|
|
447
55
|
prerender: string[];
|
|
448
|
-
routeDiscovery: {
|
|
449
|
-
mode: "lazy" | "initial";
|
|
450
|
-
manifestPath: string;
|
|
451
|
-
};
|
|
452
56
|
}
|
|
453
57
|
interface HandleDocumentRequestFunction {
|
|
454
58
|
(request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext): Promise<Response> | Response;
|
|
@@ -470,101 +74,6 @@ interface ServerEntryModule {
|
|
|
470
74
|
streamTimeout?: number;
|
|
471
75
|
}
|
|
472
76
|
|
|
473
|
-
type SerializedError = {
|
|
474
|
-
message: string;
|
|
475
|
-
stack?: string;
|
|
476
|
-
};
|
|
477
|
-
interface FrameworkContextObject {
|
|
478
|
-
manifest: AssetsManifest;
|
|
479
|
-
routeModules: RouteModules;
|
|
480
|
-
criticalCss?: CriticalCss;
|
|
481
|
-
serverHandoffString?: string;
|
|
482
|
-
future: FutureConfig;
|
|
483
|
-
ssr: boolean;
|
|
484
|
-
isSpaMode: boolean;
|
|
485
|
-
routeDiscovery: ServerBuild["routeDiscovery"];
|
|
486
|
-
serializeError?(error: Error): SerializedError;
|
|
487
|
-
renderMeta?: {
|
|
488
|
-
didRenderScripts?: boolean;
|
|
489
|
-
streamCache?: Record<number, Promise<void> & {
|
|
490
|
-
result?: {
|
|
491
|
-
done: boolean;
|
|
492
|
-
value: string;
|
|
493
|
-
};
|
|
494
|
-
error?: unknown;
|
|
495
|
-
}>;
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
interface EntryContext extends FrameworkContextObject {
|
|
499
|
-
staticHandlerContext: StaticHandlerContext;
|
|
500
|
-
serverHandoffStream?: ReadableStream<Uint8Array>;
|
|
501
|
-
}
|
|
502
|
-
interface FutureConfig {
|
|
503
|
-
unstable_subResourceIntegrity: boolean;
|
|
504
|
-
unstable_middleware: boolean;
|
|
505
|
-
}
|
|
506
|
-
type CriticalCss = string | {
|
|
507
|
-
rel: "stylesheet";
|
|
508
|
-
href: string;
|
|
509
|
-
};
|
|
510
|
-
interface AssetsManifest {
|
|
511
|
-
entry: {
|
|
512
|
-
imports: string[];
|
|
513
|
-
module: string;
|
|
514
|
-
};
|
|
515
|
-
routes: RouteManifest<EntryRoute>;
|
|
516
|
-
url: string;
|
|
517
|
-
version: string;
|
|
518
|
-
hmr?: {
|
|
519
|
-
timestamp?: number;
|
|
520
|
-
runtime: string;
|
|
521
|
-
};
|
|
522
|
-
sri?: Record<string, string> | true;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
interface Route {
|
|
526
|
-
index?: boolean;
|
|
527
|
-
caseSensitive?: boolean;
|
|
528
|
-
id: string;
|
|
529
|
-
parentId?: string;
|
|
530
|
-
path?: string;
|
|
531
|
-
}
|
|
532
|
-
interface EntryRoute extends Route {
|
|
533
|
-
hasAction: boolean;
|
|
534
|
-
hasLoader: boolean;
|
|
535
|
-
hasClientAction: boolean;
|
|
536
|
-
hasClientLoader: boolean;
|
|
537
|
-
hasClientMiddleware: boolean;
|
|
538
|
-
hasErrorBoundary: boolean;
|
|
539
|
-
imports?: string[];
|
|
540
|
-
css?: string[];
|
|
541
|
-
module: string;
|
|
542
|
-
clientActionModule: string | undefined;
|
|
543
|
-
clientLoaderModule: string | undefined;
|
|
544
|
-
clientMiddlewareModule: string | undefined;
|
|
545
|
-
hydrateFallbackModule: string | undefined;
|
|
546
|
-
parentId?: string;
|
|
547
|
-
}
|
|
548
|
-
declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
|
|
549
|
-
declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, ssr: boolean, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
|
|
550
|
-
declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
|
|
551
|
-
|
|
552
|
-
declare const SingleFetchRedirectSymbol: unique symbol;
|
|
553
|
-
declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router$1, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
|
|
554
|
-
declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
|
|
555
|
-
done: Promise<undefined>;
|
|
556
|
-
value: unknown;
|
|
557
|
-
}>;
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* The mode to use when running the server.
|
|
561
|
-
*/
|
|
562
|
-
declare enum ServerMode {
|
|
563
|
-
Development = "development",
|
|
564
|
-
Production = "production",
|
|
565
|
-
Test = "test"
|
|
566
|
-
}
|
|
567
|
-
|
|
568
77
|
/**
|
|
569
78
|
Resolves a URL against the current location.
|
|
570
79
|
|
|
@@ -665,1460 +174,272 @@ declare function useNavigate(): NavigateFunction;
|
|
|
665
174
|
*/
|
|
666
175
|
declare function useOutletContext<Context = unknown>(): Context;
|
|
667
176
|
/**
|
|
668
|
-
* Returns the element for the child route at this level of the route
|
|
669
|
-
* hierarchy. Used internally by `<Outlet>` to render child routes.
|
|
670
|
-
*
|
|
671
|
-
* @category Hooks
|
|
672
|
-
*/
|
|
673
|
-
declare function useOutlet(context?: unknown): React.ReactElement | null;
|
|
674
|
-
/**
|
|
675
|
-
Returns an object of key/value pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
|
|
676
|
-
|
|
677
|
-
```tsx
|
|
678
|
-
import { useParams } from "react-router"
|
|
679
|
-
|
|
680
|
-
function SomeComponent() {
|
|
681
|
-
let params = useParams()
|
|
682
|
-
params.postId
|
|
683
|
-
}
|
|
684
|
-
```
|
|
685
|
-
|
|
686
|
-
Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
|
|
687
|
-
|
|
688
|
-
@category Hooks
|
|
689
|
-
*/
|
|
690
|
-
declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
|
|
691
|
-
ParamsOrKey
|
|
692
|
-
] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>;
|
|
693
|
-
/**
|
|
694
|
-
Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
|
|
695
|
-
|
|
696
|
-
```tsx
|
|
697
|
-
import { useResolvedPath } from "react-router"
|
|
698
|
-
|
|
699
|
-
function SomeComponent() {
|
|
700
|
-
// if the user is at /dashboard/profile
|
|
701
|
-
let path = useResolvedPath("../accounts")
|
|
702
|
-
path.pathname // "/dashboard/accounts"
|
|
703
|
-
path.search // ""
|
|
704
|
-
path.hash // ""
|
|
705
|
-
}
|
|
706
|
-
```
|
|
707
|
-
|
|
708
|
-
@category Hooks
|
|
709
|
-
*/
|
|
710
|
-
declare function useResolvedPath(to: To, { relative }?: {
|
|
711
|
-
relative?: RelativeRoutingType;
|
|
712
|
-
}): Path;
|
|
713
|
-
/**
|
|
714
|
-
Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
|
|
715
|
-
|
|
716
|
-
The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
|
|
717
|
-
|
|
718
|
-
```tsx
|
|
719
|
-
import * as React from "react";
|
|
720
|
-
import { useRoutes } from "react-router";
|
|
721
|
-
|
|
722
|
-
function App() {
|
|
723
|
-
let element = useRoutes([
|
|
724
|
-
{
|
|
725
|
-
path: "/",
|
|
726
|
-
element: <Dashboard />,
|
|
727
|
-
children: [
|
|
728
|
-
{
|
|
729
|
-
path: "messages",
|
|
730
|
-
element: <DashboardMessages />,
|
|
731
|
-
},
|
|
732
|
-
{ path: "tasks", element: <DashboardTasks /> },
|
|
733
|
-
],
|
|
734
|
-
},
|
|
735
|
-
{ path: "team", element: <AboutPage /> },
|
|
736
|
-
]);
|
|
737
|
-
|
|
738
|
-
return element;
|
|
739
|
-
}
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
@category Hooks
|
|
743
|
-
*/
|
|
744
|
-
declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
|
|
745
|
-
/**
|
|
746
|
-
Returns the current navigation, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read FormData from a form navigation.
|
|
747
|
-
|
|
748
|
-
```tsx
|
|
749
|
-
import { useNavigation } from "react-router"
|
|
750
|
-
|
|
751
|
-
function SomeComponent() {
|
|
752
|
-
let navigation = useNavigation();
|
|
753
|
-
navigation.state
|
|
754
|
-
navigation.formData
|
|
755
|
-
// etc.
|
|
756
|
-
}
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
@category Hooks
|
|
760
|
-
*/
|
|
761
|
-
declare function useNavigation(): Navigation;
|
|
762
|
-
/**
|
|
763
|
-
Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
|
|
764
|
-
|
|
765
|
-
```tsx
|
|
766
|
-
import { useRevalidator } from "react-router";
|
|
767
|
-
|
|
768
|
-
function WindowFocusRevalidator() {
|
|
769
|
-
const revalidator = useRevalidator();
|
|
770
|
-
|
|
771
|
-
useFakeWindowFocus(() => {
|
|
772
|
-
revalidator.revalidate();
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
return (
|
|
776
|
-
<div hidden={revalidator.state === "idle"}>
|
|
777
|
-
Revalidating...
|
|
778
|
-
</div>
|
|
779
|
-
);
|
|
780
|
-
}
|
|
781
|
-
```
|
|
782
|
-
|
|
783
|
-
Note that page data is already revalidated automatically after actions. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
|
|
784
|
-
|
|
785
|
-
@category Hooks
|
|
786
|
-
*/
|
|
787
|
-
declare function useRevalidator(): {
|
|
788
|
-
revalidate(): Promise<void>;
|
|
789
|
-
state: RevalidationState;
|
|
790
|
-
};
|
|
791
|
-
/**
|
|
792
|
-
* Returns the active route matches, useful for accessing loaderData for
|
|
793
|
-
* parent/child routes or the route "handle" property
|
|
794
|
-
*
|
|
795
|
-
* @category Hooks
|
|
796
|
-
*/
|
|
797
|
-
declare function useMatches(): UIMatch[];
|
|
798
|
-
/**
|
|
799
|
-
Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
|
|
800
|
-
|
|
801
|
-
```tsx
|
|
802
|
-
import { useLoaderData } from "react-router"
|
|
803
|
-
|
|
804
|
-
export async function loader() {
|
|
805
|
-
return await fakeDb.invoices.findAll();
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
export default function Invoices() {
|
|
809
|
-
let invoices = useLoaderData<typeof loader>();
|
|
810
|
-
// ...
|
|
811
|
-
}
|
|
812
|
-
```
|
|
813
|
-
|
|
814
|
-
@category Hooks
|
|
815
|
-
*/
|
|
816
|
-
declare function useLoaderData<T = any>(): SerializeFrom<T>;
|
|
817
|
-
/**
|
|
818
|
-
Returns the loader data for a given route by route ID.
|
|
819
|
-
|
|
820
|
-
```tsx
|
|
821
|
-
import { useRouteLoaderData } from "react-router";
|
|
822
|
-
|
|
823
|
-
function SomeComponent() {
|
|
824
|
-
const { user } = useRouteLoaderData("root");
|
|
825
|
-
}
|
|
826
|
-
```
|
|
827
|
-
|
|
828
|
-
Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
|
|
829
|
-
|
|
830
|
-
| Route Filename | Route ID |
|
|
831
|
-
| -------------------------- | -------------------- |
|
|
832
|
-
| `app/root.tsx` | `"root"` |
|
|
833
|
-
| `app/routes/teams.tsx` | `"routes/teams"` |
|
|
834
|
-
| `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
|
|
835
|
-
|
|
836
|
-
If you created an ID manually, you can use that instead:
|
|
837
|
-
|
|
838
|
-
```tsx
|
|
839
|
-
route("/", "containers/app.tsx", { id: "app" }})
|
|
840
|
-
```
|
|
841
|
-
|
|
842
|
-
@category Hooks
|
|
843
|
-
*/
|
|
844
|
-
declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
|
|
845
|
-
/**
|
|
846
|
-
Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
|
|
847
|
-
|
|
848
|
-
```tsx
|
|
849
|
-
import { Form, useActionData } from "react-router"
|
|
850
|
-
|
|
851
|
-
export async function action({ request }) {
|
|
852
|
-
const body = await request.formData()
|
|
853
|
-
const name = body.get("visitorsName")
|
|
854
|
-
return { message: `Hello, ${name}` }
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
export default function Invoices() {
|
|
858
|
-
const data = useActionData()
|
|
859
|
-
return (
|
|
860
|
-
<Form method="post">
|
|
861
|
-
<input type="text" name="visitorsName" />
|
|
862
|
-
{data ? data.message : "Waiting..."}
|
|
863
|
-
</Form>
|
|
864
|
-
)
|
|
865
|
-
}
|
|
866
|
-
```
|
|
867
|
-
|
|
868
|
-
@category Hooks
|
|
869
|
-
*/
|
|
870
|
-
declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
|
|
871
|
-
/**
|
|
872
|
-
Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
|
|
873
|
-
|
|
874
|
-
```tsx
|
|
875
|
-
export function ErrorBoundary() {
|
|
876
|
-
const error = useRouteError();
|
|
877
|
-
return <div>{error.message}</div>;
|
|
878
|
-
}
|
|
879
|
-
```
|
|
880
|
-
|
|
881
|
-
@category Hooks
|
|
882
|
-
*/
|
|
883
|
-
declare function useRouteError(): unknown;
|
|
884
|
-
/**
|
|
885
|
-
Returns the resolved promise value from the closest {@link Await | `<Await>`}.
|
|
886
|
-
|
|
887
|
-
```tsx
|
|
888
|
-
function SomeDescendant() {
|
|
889
|
-
const value = useAsyncValue();
|
|
890
|
-
// ...
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
// somewhere in your app
|
|
894
|
-
<Await resolve={somePromise}>
|
|
895
|
-
<SomeDescendant />
|
|
896
|
-
</Await>
|
|
897
|
-
```
|
|
898
|
-
|
|
899
|
-
@category Hooks
|
|
900
|
-
*/
|
|
901
|
-
declare function useAsyncValue(): unknown;
|
|
902
|
-
/**
|
|
903
|
-
Returns the rejection value from the closest {@link Await | `<Await>`}.
|
|
904
|
-
|
|
905
|
-
```tsx
|
|
906
|
-
import { Await, useAsyncError } from "react-router"
|
|
907
|
-
|
|
908
|
-
function ErrorElement() {
|
|
909
|
-
const error = useAsyncError();
|
|
910
|
-
return (
|
|
911
|
-
<p>Uh Oh, something went wrong! {error.message}</p>
|
|
912
|
-
);
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
// somewhere in your app
|
|
916
|
-
<Await
|
|
917
|
-
resolve={promiseThatRejects}
|
|
918
|
-
errorElement={<ErrorElement />}
|
|
919
|
-
/>
|
|
920
|
-
```
|
|
921
|
-
|
|
922
|
-
@category Hooks
|
|
923
|
-
*/
|
|
924
|
-
declare function useAsyncError(): unknown;
|
|
925
|
-
/**
|
|
926
|
-
* Allow the application to block navigations within the SPA and present the
|
|
927
|
-
* user a confirmation dialog to confirm the navigation. Mostly used to avoid
|
|
928
|
-
* using half-filled form data. This does not handle hard-reloads or
|
|
929
|
-
* cross-origin navigations.
|
|
930
|
-
*
|
|
931
|
-
* @category Hooks
|
|
932
|
-
*/
|
|
933
|
-
declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
|
|
934
|
-
|
|
935
|
-
type ParamKeyValuePair = [string, string];
|
|
936
|
-
type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
|
|
937
|
-
/**
|
|
938
|
-
Creates a URLSearchParams object using the given initializer.
|
|
939
|
-
|
|
940
|
-
This is identical to `new URLSearchParams(init)` except it also
|
|
941
|
-
supports arrays as values in the object form of the initializer
|
|
942
|
-
instead of just strings. This is convenient when you need multiple
|
|
943
|
-
values for a given key, but don't want to use an array initializer.
|
|
944
|
-
|
|
945
|
-
For example, instead of:
|
|
946
|
-
|
|
947
|
-
```tsx
|
|
948
|
-
let searchParams = new URLSearchParams([
|
|
949
|
-
['sort', 'name'],
|
|
950
|
-
['sort', 'price']
|
|
951
|
-
]);
|
|
952
|
-
```
|
|
953
|
-
you can do:
|
|
954
|
-
|
|
955
|
-
```
|
|
956
|
-
let searchParams = createSearchParams({
|
|
957
|
-
sort: ['name', 'price']
|
|
958
|
-
});
|
|
959
|
-
```
|
|
960
|
-
|
|
961
|
-
@category Utils
|
|
962
|
-
*/
|
|
963
|
-
declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
|
|
964
|
-
type JsonObject = {
|
|
965
|
-
[Key in string]: JsonValue;
|
|
966
|
-
} & {
|
|
967
|
-
[Key in string]?: JsonValue | undefined;
|
|
968
|
-
};
|
|
969
|
-
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
970
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
971
|
-
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
972
|
-
type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
|
|
973
|
-
/**
|
|
974
|
-
* Submit options shared by both navigations and fetchers
|
|
975
|
-
*/
|
|
976
|
-
interface SharedSubmitOptions {
|
|
977
|
-
/**
|
|
978
|
-
* The HTTP method used to submit the form. Overrides `<form method>`.
|
|
979
|
-
* Defaults to "GET".
|
|
980
|
-
*/
|
|
981
|
-
method?: HTMLFormMethod;
|
|
982
|
-
/**
|
|
983
|
-
* The action URL path used to submit the form. Overrides `<form action>`.
|
|
984
|
-
* Defaults to the path of the current route.
|
|
985
|
-
*/
|
|
986
|
-
action?: string;
|
|
987
|
-
/**
|
|
988
|
-
* The encoding used to submit the form. Overrides `<form encType>`.
|
|
989
|
-
* Defaults to "application/x-www-form-urlencoded".
|
|
990
|
-
*/
|
|
991
|
-
encType?: FormEncType;
|
|
992
|
-
/**
|
|
993
|
-
* Determines whether the form action is relative to the route hierarchy or
|
|
994
|
-
* the pathname. Use this if you want to opt out of navigating the route
|
|
995
|
-
* hierarchy and want to instead route based on /-delimited URL segments
|
|
996
|
-
*/
|
|
997
|
-
relative?: RelativeRoutingType;
|
|
998
|
-
/**
|
|
999
|
-
* In browser-based environments, prevent resetting scroll after this
|
|
1000
|
-
* navigation when using the <ScrollRestoration> component
|
|
1001
|
-
*/
|
|
1002
|
-
preventScrollReset?: boolean;
|
|
1003
|
-
/**
|
|
1004
|
-
* Enable flushSync for this submission's state updates
|
|
1005
|
-
*/
|
|
1006
|
-
flushSync?: boolean;
|
|
1007
|
-
}
|
|
1008
|
-
/**
|
|
1009
|
-
* Submit options available to fetchers
|
|
1010
|
-
*/
|
|
1011
|
-
interface FetcherSubmitOptions extends SharedSubmitOptions {
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Submit options available to navigations
|
|
1015
|
-
*/
|
|
1016
|
-
interface SubmitOptions extends FetcherSubmitOptions {
|
|
1017
|
-
/**
|
|
1018
|
-
* Set `true` to replace the current entry in the browser's history stack
|
|
1019
|
-
* instead of creating a new one (i.e. stay on "the same page"). Defaults
|
|
1020
|
-
* to `false`.
|
|
1021
|
-
*/
|
|
1022
|
-
replace?: boolean;
|
|
1023
|
-
/**
|
|
1024
|
-
* State object to add to the history stack entry for this navigation
|
|
1025
|
-
*/
|
|
1026
|
-
state?: any;
|
|
1027
|
-
/**
|
|
1028
|
-
* Indicate a specific fetcherKey to use when using navigate=false
|
|
1029
|
-
*/
|
|
1030
|
-
fetcherKey?: string;
|
|
1031
|
-
/**
|
|
1032
|
-
* navigate=false will use a fetcher instead of a navigation
|
|
1033
|
-
*/
|
|
1034
|
-
navigate?: boolean;
|
|
1035
|
-
/**
|
|
1036
|
-
* Enable view transitions on this submission navigation
|
|
1037
|
-
*/
|
|
1038
|
-
viewTransition?: boolean;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
|
|
1042
|
-
/**
|
|
1043
|
-
* Defines the discovery behavior of the link:
|
|
1044
|
-
*
|
|
1045
|
-
* - "render" - default, discover the route when the link renders
|
|
1046
|
-
* - "none" - don't eagerly discover, only discover if the link is clicked
|
|
1047
|
-
*/
|
|
1048
|
-
type DiscoverBehavior = "render" | "none";
|
|
1049
|
-
/**
|
|
1050
|
-
* Defines the prefetching behavior of the link:
|
|
1051
|
-
*
|
|
1052
|
-
* - "none": Never fetched
|
|
1053
|
-
* - "intent": Fetched when the user focuses or hovers the link
|
|
1054
|
-
* - "render": Fetched when the link is rendered
|
|
1055
|
-
* - "viewport": Fetched when the link is in the viewport
|
|
1056
|
-
*/
|
|
1057
|
-
type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
|
|
1058
|
-
/**
|
|
1059
|
-
Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
|
|
1060
|
-
|
|
1061
|
-
```tsx
|
|
1062
|
-
import { Links } from "react-router";
|
|
1063
|
-
|
|
1064
|
-
export default function Root() {
|
|
1065
|
-
return (
|
|
1066
|
-
<html>
|
|
1067
|
-
<head>
|
|
1068
|
-
<Links />
|
|
1069
|
-
</head>
|
|
1070
|
-
<body></body>
|
|
1071
|
-
</html>
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
1074
|
-
```
|
|
1075
|
-
|
|
1076
|
-
@category Components
|
|
1077
|
-
*/
|
|
1078
|
-
declare function Links(): React.JSX.Element;
|
|
1079
|
-
/**
|
|
1080
|
-
Renders `<link rel=prefetch|modulepreload>` tags for modules and data of another page to enable an instant navigation to that page. {@link LinkProps.prefetch | `<Link prefetch>`} uses this internally, but you can render it to prefetch a page for any other reason.
|
|
1081
|
-
|
|
1082
|
-
```tsx
|
|
1083
|
-
import { PrefetchPageLinks } from "react-router"
|
|
1084
|
-
|
|
1085
|
-
<PrefetchPageLinks page="/absolute/path" />
|
|
1086
|
-
```
|
|
1087
|
-
|
|
1088
|
-
For example, you may render one of this as the user types into a search field to prefetch search results before they click through to their selection.
|
|
1089
|
-
|
|
1090
|
-
@category Components
|
|
1091
|
-
*/
|
|
1092
|
-
declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
|
|
1093
|
-
/**
|
|
1094
|
-
Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
|
|
1095
|
-
|
|
1096
|
-
```tsx
|
|
1097
|
-
import { Meta } from "react-router";
|
|
1098
|
-
|
|
1099
|
-
export default function Root() {
|
|
1100
|
-
return (
|
|
1101
|
-
<html>
|
|
1102
|
-
<head>
|
|
1103
|
-
<Meta />
|
|
1104
|
-
</head>
|
|
1105
|
-
</html>
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
```
|
|
1109
|
-
|
|
1110
|
-
@category Components
|
|
1111
|
-
*/
|
|
1112
|
-
declare function Meta(): React.JSX.Element;
|
|
1113
|
-
/**
|
|
1114
|
-
A couple common attributes:
|
|
1115
|
-
|
|
1116
|
-
- `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
|
|
1117
|
-
- `<Scripts nonce>` to support a [content security policy for scripts](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) with [nonce-sources](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#sources) for your `<script>` tags.
|
|
1118
|
-
|
|
1119
|
-
You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
|
|
1120
|
-
|
|
1121
|
-
@category Types
|
|
1122
|
-
*/
|
|
1123
|
-
type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
|
|
1124
|
-
/**
|
|
1125
|
-
Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
|
|
1126
|
-
|
|
1127
|
-
```tsx
|
|
1128
|
-
import { Scripts } from "react-router";
|
|
1129
|
-
|
|
1130
|
-
export default function Root() {
|
|
1131
|
-
return (
|
|
1132
|
-
<html>
|
|
1133
|
-
<head />
|
|
1134
|
-
<body>
|
|
1135
|
-
<Scripts />
|
|
1136
|
-
</body>
|
|
1137
|
-
</html>
|
|
1138
|
-
);
|
|
1139
|
-
}
|
|
1140
|
-
```
|
|
1141
|
-
|
|
1142
|
-
If server rendering, you can omit `<Scripts/>` and the app will work as a traditional web app without JavaScript, relying solely on HTML and browser behaviors.
|
|
1143
|
-
|
|
1144
|
-
@category Components
|
|
1145
|
-
*/
|
|
1146
|
-
declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
|
|
1147
|
-
|
|
1148
|
-
declare global {
|
|
1149
|
-
const REACT_ROUTER_VERSION: string;
|
|
1150
|
-
}
|
|
1151
|
-
/**
|
|
1152
|
-
* @category Routers
|
|
1153
|
-
*/
|
|
1154
|
-
interface DOMRouterOpts {
|
|
1155
|
-
/**
|
|
1156
|
-
* Basename path for the application.
|
|
1157
|
-
*/
|
|
1158
|
-
basename?: string;
|
|
1159
|
-
/**
|
|
1160
|
-
* Function to provide the initial context values for all client side navigations/fetches
|
|
1161
|
-
*/
|
|
1162
|
-
unstable_getContext?: RouterInit["unstable_getContext"];
|
|
1163
|
-
/**
|
|
1164
|
-
* Future flags to enable for the router.
|
|
1165
|
-
*/
|
|
1166
|
-
future?: Partial<FutureConfig$1>;
|
|
1167
|
-
/**
|
|
1168
|
-
* Hydration data to initialize the router with if you have already performed
|
|
1169
|
-
* data loading on the server.
|
|
1170
|
-
*/
|
|
1171
|
-
hydrationData?: HydrationState;
|
|
1172
|
-
/**
|
|
1173
|
-
* Override the default data strategy of loading in parallel.
|
|
1174
|
-
* Only intended for advanced usage.
|
|
1175
|
-
*/
|
|
1176
|
-
dataStrategy?: DataStrategyFunction;
|
|
1177
|
-
/**
|
|
1178
|
-
* Lazily define portions of the route tree on navigations.
|
|
1179
|
-
*/
|
|
1180
|
-
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
|
1181
|
-
/**
|
|
1182
|
-
* Window object override - defaults to the global `window` instance.
|
|
1183
|
-
*/
|
|
1184
|
-
window?: Window;
|
|
1185
|
-
}
|
|
1186
|
-
/**
|
|
1187
|
-
* Create a new data router that manages the application path via `history.pushState`
|
|
1188
|
-
* and `history.replaceState`.
|
|
1189
|
-
*
|
|
1190
|
-
* @category Data Routers
|
|
1191
|
-
*/
|
|
1192
|
-
declare function createBrowserRouter(
|
|
1193
|
-
/**
|
|
1194
|
-
* Application routes
|
|
1195
|
-
*/
|
|
1196
|
-
routes: RouteObject[],
|
|
1197
|
-
/**
|
|
1198
|
-
* Router options
|
|
1199
|
-
*/
|
|
1200
|
-
opts?: DOMRouterOpts): Router$1;
|
|
1201
|
-
/**
|
|
1202
|
-
* Create a new data router that manages the application path via the URL hash
|
|
1203
|
-
*
|
|
1204
|
-
* @category Data Routers
|
|
1205
|
-
*/
|
|
1206
|
-
declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
|
|
1207
|
-
/**
|
|
1208
|
-
* @category Types
|
|
1209
|
-
*/
|
|
1210
|
-
interface BrowserRouterProps {
|
|
1211
|
-
basename?: string;
|
|
1212
|
-
children?: React.ReactNode;
|
|
1213
|
-
window?: Window;
|
|
1214
|
-
}
|
|
1215
|
-
/**
|
|
1216
|
-
* A `<Router>` for use in web browsers. Provides the cleanest URLs.
|
|
1217
|
-
*
|
|
1218
|
-
* @category Component Routers
|
|
1219
|
-
*/
|
|
1220
|
-
declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
|
|
1221
|
-
/**
|
|
1222
|
-
* @category Types
|
|
1223
|
-
*/
|
|
1224
|
-
interface HashRouterProps {
|
|
1225
|
-
basename?: string;
|
|
1226
|
-
children?: React.ReactNode;
|
|
1227
|
-
window?: Window;
|
|
1228
|
-
}
|
|
1229
|
-
/**
|
|
1230
|
-
* A `<Router>` for use in web browsers. Stores the location in the hash
|
|
1231
|
-
* portion of the URL so it is not sent to the server.
|
|
1232
|
-
*
|
|
1233
|
-
* @category Component Routers
|
|
1234
|
-
*/
|
|
1235
|
-
declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
|
|
1236
|
-
/**
|
|
1237
|
-
* @category Types
|
|
1238
|
-
*/
|
|
1239
|
-
interface HistoryRouterProps {
|
|
1240
|
-
basename?: string;
|
|
1241
|
-
children?: React.ReactNode;
|
|
1242
|
-
history: History;
|
|
1243
|
-
}
|
|
1244
|
-
/**
|
|
1245
|
-
* A `<Router>` that accepts a pre-instantiated history object. It's important
|
|
1246
|
-
* to note that using your own history object is highly discouraged and may add
|
|
1247
|
-
* two versions of the history library to your bundles unless you use the same
|
|
1248
|
-
* version of the history library that React Router uses internally.
|
|
1249
|
-
*
|
|
1250
|
-
* @name unstable_HistoryRouter
|
|
1251
|
-
* @category Component Routers
|
|
1252
|
-
*/
|
|
1253
|
-
declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
|
|
1254
|
-
declare namespace HistoryRouter {
|
|
1255
|
-
var displayName: string;
|
|
1256
|
-
}
|
|
1257
|
-
/**
|
|
1258
|
-
* @category Types
|
|
1259
|
-
*/
|
|
1260
|
-
interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
|
1261
|
-
/**
|
|
1262
|
-
Defines the link discovery behavior
|
|
1263
|
-
|
|
1264
|
-
```tsx
|
|
1265
|
-
<Link /> // default ("render")
|
|
1266
|
-
<Link discover="render" />
|
|
1267
|
-
<Link discover="none" />
|
|
1268
|
-
```
|
|
1269
|
-
|
|
1270
|
-
- **render** - default, discover the route when the link renders
|
|
1271
|
-
- **none** - don't eagerly discover, only discover if the link is clicked
|
|
1272
|
-
*/
|
|
1273
|
-
discover?: DiscoverBehavior;
|
|
1274
|
-
/**
|
|
1275
|
-
Defines the data and module prefetching behavior for the link.
|
|
1276
|
-
|
|
1277
|
-
```tsx
|
|
1278
|
-
<Link /> // default
|
|
1279
|
-
<Link prefetch="none" />
|
|
1280
|
-
<Link prefetch="intent" />
|
|
1281
|
-
<Link prefetch="render" />
|
|
1282
|
-
<Link prefetch="viewport" />
|
|
1283
|
-
```
|
|
1284
|
-
|
|
1285
|
-
- **none** - default, no prefetching
|
|
1286
|
-
- **intent** - prefetches when the user hovers or focuses the link
|
|
1287
|
-
- **render** - prefetches when the link renders
|
|
1288
|
-
- **viewport** - prefetches when the link is in the viewport, very useful for mobile
|
|
1289
|
-
|
|
1290
|
-
Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
|
|
1291
|
-
|
|
1292
|
-
```tsx
|
|
1293
|
-
<a href="..." />
|
|
1294
|
-
<a href="..." />
|
|
1295
|
-
<link rel="prefetch" /> // might conditionally render
|
|
1296
|
-
```
|
|
1297
|
-
|
|
1298
|
-
Because of this, if you are using `nav :last-child` you will need to use `nav :last-of-type` so the styles don't conditionally fall off your last link (and any other similar selectors).
|
|
1299
|
-
*/
|
|
1300
|
-
prefetch?: PrefetchBehavior;
|
|
1301
|
-
/**
|
|
1302
|
-
Will use document navigation instead of client side routing when the link is clicked: the browser will handle the transition normally (as if it were an `<a href>`).
|
|
1303
|
-
|
|
1304
|
-
```tsx
|
|
1305
|
-
<Link to="/logout" reloadDocument />
|
|
1306
|
-
```
|
|
1307
|
-
*/
|
|
1308
|
-
reloadDocument?: boolean;
|
|
1309
|
-
/**
|
|
1310
|
-
Replaces the current entry in the history stack instead of pushing a new one onto it.
|
|
1311
|
-
|
|
1312
|
-
```tsx
|
|
1313
|
-
<Link replace />
|
|
1314
|
-
```
|
|
1315
|
-
|
|
1316
|
-
```
|
|
1317
|
-
# with a history stack like this
|
|
1318
|
-
A -> B
|
|
1319
|
-
|
|
1320
|
-
# normal link click pushes a new entry
|
|
1321
|
-
A -> B -> C
|
|
1322
|
-
|
|
1323
|
-
# but with `replace`, B is replaced by C
|
|
1324
|
-
A -> C
|
|
1325
|
-
```
|
|
1326
|
-
*/
|
|
1327
|
-
replace?: boolean;
|
|
1328
|
-
/**
|
|
1329
|
-
Adds persistent client side routing state to the next location.
|
|
1330
|
-
|
|
1331
|
-
```tsx
|
|
1332
|
-
<Link to="/somewhere/else" state={{ some: "value" }} />
|
|
1333
|
-
```
|
|
1334
|
-
|
|
1335
|
-
The location state is accessed from the `location`.
|
|
1336
|
-
|
|
1337
|
-
```tsx
|
|
1338
|
-
function SomeComp() {
|
|
1339
|
-
const location = useLocation()
|
|
1340
|
-
location.state; // { some: "value" }
|
|
1341
|
-
}
|
|
1342
|
-
```
|
|
1343
|
-
|
|
1344
|
-
This state is inaccessible on the server as it is implemented on top of [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
|
|
1345
|
-
*/
|
|
1346
|
-
state?: any;
|
|
1347
|
-
/**
|
|
1348
|
-
Prevents the scroll position from being reset to the top of the window when the link is clicked and the app is using {@link ScrollRestoration}. This only prevents new locations reseting scroll to the top, scroll position will be restored for back/forward button navigation.
|
|
1349
|
-
|
|
1350
|
-
```tsx
|
|
1351
|
-
<Link to="?tab=one" preventScrollReset />
|
|
1352
|
-
```
|
|
1353
|
-
*/
|
|
1354
|
-
preventScrollReset?: boolean;
|
|
1355
|
-
/**
|
|
1356
|
-
Defines the relative path behavior for the link.
|
|
1357
|
-
|
|
1358
|
-
```tsx
|
|
1359
|
-
<Link to=".." /> // default: "route"
|
|
1360
|
-
<Link relative="route" />
|
|
1361
|
-
<Link relative="path" />
|
|
1362
|
-
```
|
|
1363
|
-
|
|
1364
|
-
Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
|
|
1365
|
-
|
|
1366
|
-
- **route** - default, resolves the link relative to the route pattern. In the example above a relative link of `".."` will remove both `:slug/edit` segments back to "/blog".
|
|
1367
|
-
- **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
|
|
1368
|
-
*/
|
|
1369
|
-
relative?: RelativeRoutingType;
|
|
1370
|
-
/**
|
|
1371
|
-
Can be a string or a partial {@link Path}:
|
|
1372
|
-
|
|
1373
|
-
```tsx
|
|
1374
|
-
<Link to="/some/path" />
|
|
1375
|
-
|
|
1376
|
-
<Link
|
|
1377
|
-
to={{
|
|
1378
|
-
pathname: "/some/path",
|
|
1379
|
-
search: "?query=string",
|
|
1380
|
-
hash: "#hash",
|
|
1381
|
-
}}
|
|
1382
|
-
/>
|
|
1383
|
-
```
|
|
1384
|
-
*/
|
|
1385
|
-
to: To;
|
|
1386
|
-
/**
|
|
1387
|
-
Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
|
|
1388
|
-
|
|
1389
|
-
```jsx
|
|
1390
|
-
<Link to={to} viewTransition>
|
|
1391
|
-
Click me
|
|
1392
|
-
</Link>
|
|
1393
|
-
```
|
|
1394
|
-
|
|
1395
|
-
To apply specific styles for the transition, see {@link useViewTransitionState}
|
|
1396
|
-
*/
|
|
1397
|
-
viewTransition?: boolean;
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
A progressively enhanced `<a href>` wrapper to enable navigation with client-side routing.
|
|
1401
|
-
|
|
1402
|
-
```tsx
|
|
1403
|
-
import { Link } from "react-router";
|
|
1404
|
-
|
|
1405
|
-
<Link to="/dashboard">Dashboard</Link>;
|
|
1406
|
-
|
|
1407
|
-
<Link
|
|
1408
|
-
to={{
|
|
1409
|
-
pathname: "/some/path",
|
|
1410
|
-
search: "?query=string",
|
|
1411
|
-
hash: "#hash",
|
|
1412
|
-
}}
|
|
1413
|
-
/>
|
|
1414
|
-
```
|
|
1415
|
-
|
|
1416
|
-
@category Components
|
|
1417
|
-
*/
|
|
1418
|
-
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
1419
|
-
/**
|
|
1420
|
-
The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
|
|
1421
|
-
|
|
1422
|
-
```
|
|
1423
|
-
// className
|
|
1424
|
-
<NavLink
|
|
1425
|
-
to="/messages"
|
|
1426
|
-
className={({ isActive, isPending }) =>
|
|
1427
|
-
isPending ? "pending" : isActive ? "active" : ""
|
|
1428
|
-
}
|
|
1429
|
-
>
|
|
1430
|
-
Messages
|
|
1431
|
-
</NavLink>
|
|
1432
|
-
|
|
1433
|
-
// style
|
|
1434
|
-
<NavLink
|
|
1435
|
-
to="/messages"
|
|
1436
|
-
style={({ isActive, isPending }) => {
|
|
1437
|
-
return {
|
|
1438
|
-
fontWeight: isActive ? "bold" : "",
|
|
1439
|
-
color: isPending ? "red" : "black",
|
|
1440
|
-
}
|
|
1441
|
-
)}
|
|
1442
|
-
/>
|
|
1443
|
-
|
|
1444
|
-
// children
|
|
1445
|
-
<NavLink to="/tasks">
|
|
1446
|
-
{({ isActive, isPending }) => (
|
|
1447
|
-
<span className={isActive ? "active" : ""}>Tasks</span>
|
|
1448
|
-
)}
|
|
1449
|
-
</NavLink>
|
|
1450
|
-
```
|
|
1451
|
-
|
|
1452
|
-
*/
|
|
1453
|
-
type NavLinkRenderProps = {
|
|
1454
|
-
/**
|
|
1455
|
-
* Indicates if the link's URL matches the current location.
|
|
1456
|
-
*/
|
|
1457
|
-
isActive: boolean;
|
|
1458
|
-
/**
|
|
1459
|
-
* Indicates if the pending location matches the link's URL.
|
|
1460
|
-
*/
|
|
1461
|
-
isPending: boolean;
|
|
1462
|
-
/**
|
|
1463
|
-
* Indicates if a view transition to the link's URL is in progress. See {@link useViewTransitionState}
|
|
1464
|
-
*/
|
|
1465
|
-
isTransitioning: boolean;
|
|
1466
|
-
};
|
|
1467
|
-
/**
|
|
1468
|
-
* @category Types
|
|
1469
|
-
*/
|
|
1470
|
-
interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
|
|
1471
|
-
/**
|
|
1472
|
-
Can be regular React children or a function that receives an object with the active and pending states of the link.
|
|
1473
|
-
|
|
1474
|
-
```tsx
|
|
1475
|
-
<NavLink to="/tasks">
|
|
1476
|
-
{({ isActive }) => (
|
|
1477
|
-
<span className={isActive ? "active" : ""}>Tasks</span>
|
|
1478
|
-
)}
|
|
1479
|
-
</NavLink>
|
|
1480
|
-
```
|
|
1481
|
-
*/
|
|
1482
|
-
children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
|
|
1483
|
-
/**
|
|
1484
|
-
Changes the matching logic to make it case-sensitive:
|
|
1485
|
-
|
|
1486
|
-
| Link | URL | isActive |
|
|
1487
|
-
| -------------------------------------------- | ------------- | -------- |
|
|
1488
|
-
| `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
|
|
1489
|
-
| `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
|
|
1490
|
-
*/
|
|
1491
|
-
caseSensitive?: boolean;
|
|
1492
|
-
/**
|
|
1493
|
-
Classes are automatically applied to NavLink that correspond to {@link NavLinkRenderProps}.
|
|
1494
|
-
|
|
1495
|
-
```css
|
|
1496
|
-
a.active { color: red; }
|
|
1497
|
-
a.pending { color: blue; }
|
|
1498
|
-
a.transitioning {
|
|
1499
|
-
view-transition-name: my-transition;
|
|
1500
|
-
}
|
|
1501
|
-
```
|
|
1502
|
-
*/
|
|
1503
|
-
className?: string | ((props: NavLinkRenderProps) => string | undefined);
|
|
1504
|
-
/**
|
|
1505
|
-
Changes the matching logic for the `active` and `pending` states to only match to the "end" of the {@link NavLinkProps.to}. If the URL is longer, it will no longer be considered active.
|
|
1506
|
-
|
|
1507
|
-
| Link | URL | isActive |
|
|
1508
|
-
| ----------------------------- | ------------ | -------- |
|
|
1509
|
-
| `<NavLink to="/tasks" />` | `/tasks` | true |
|
|
1510
|
-
| `<NavLink to="/tasks" />` | `/tasks/123` | true |
|
|
1511
|
-
| `<NavLink to="/tasks" end />` | `/tasks` | true |
|
|
1512
|
-
| `<NavLink to="/tasks" end />` | `/tasks/123` | false |
|
|
1513
|
-
|
|
1514
|
-
`<NavLink to="/">` is an exceptional case because _every_ URL matches `/`. To avoid this matching every single route by default, it effectively ignores the `end` prop and only matches when you're at the root route.
|
|
1515
|
-
*/
|
|
1516
|
-
end?: boolean;
|
|
1517
|
-
style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
|
|
1518
|
-
}
|
|
1519
|
-
/**
|
|
1520
|
-
Wraps {@link Link | `<Link>`} with additional props for styling active and pending states.
|
|
1521
|
-
|
|
1522
|
-
- Automatically applies classes to the link based on its active and pending states, see {@link NavLinkProps.className}.
|
|
1523
|
-
- Automatically applies `aria-current="page"` to the link when the link is active. See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current) on MDN.
|
|
1524
|
-
|
|
1525
|
-
```tsx
|
|
1526
|
-
import { NavLink } from "react-router"
|
|
1527
|
-
<NavLink to="/message" />
|
|
1528
|
-
```
|
|
1529
|
-
|
|
1530
|
-
States are available through the className, style, and children render props. See {@link NavLinkRenderProps}.
|
|
1531
|
-
|
|
1532
|
-
```tsx
|
|
1533
|
-
<NavLink
|
|
1534
|
-
to="/messages"
|
|
1535
|
-
className={({ isActive, isPending }) =>
|
|
1536
|
-
isPending ? "pending" : isActive ? "active" : ""
|
|
1537
|
-
}
|
|
1538
|
-
>
|
|
1539
|
-
Messages
|
|
1540
|
-
</NavLink>
|
|
1541
|
-
```
|
|
1542
|
-
|
|
1543
|
-
@category Components
|
|
1544
|
-
*/
|
|
1545
|
-
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
1546
|
-
/**
|
|
1547
|
-
* Form props shared by navigations and fetchers
|
|
1548
|
-
*/
|
|
1549
|
-
interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
1550
|
-
/**
|
|
1551
|
-
* The HTTP verb to use when the form is submitted. Supports "get", "post",
|
|
1552
|
-
* "put", "delete", and "patch".
|
|
1553
|
-
*
|
|
1554
|
-
* Native `<form>` only supports `get` and `post`, avoid the other verbs if
|
|
1555
|
-
* you'd like to support progressive enhancement
|
|
1556
|
-
*/
|
|
1557
|
-
method?: HTMLFormMethod;
|
|
1558
|
-
/**
|
|
1559
|
-
* The encoding type to use for the form submission.
|
|
1560
|
-
*/
|
|
1561
|
-
encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
1562
|
-
/**
|
|
1563
|
-
* The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
|
|
1564
|
-
*/
|
|
1565
|
-
action?: string;
|
|
1566
|
-
/**
|
|
1567
|
-
* Determines whether the form action is relative to the route hierarchy or
|
|
1568
|
-
* the pathname. Use this if you want to opt out of navigating the route
|
|
1569
|
-
* hierarchy and want to instead route based on /-delimited URL segments
|
|
1570
|
-
*/
|
|
1571
|
-
relative?: RelativeRoutingType;
|
|
1572
|
-
/**
|
|
1573
|
-
* Prevent the scroll position from resetting to the top of the viewport on
|
|
1574
|
-
* completion of the navigation when using the <ScrollRestoration> component
|
|
1575
|
-
*/
|
|
1576
|
-
preventScrollReset?: boolean;
|
|
1577
|
-
/**
|
|
1578
|
-
* A function to call when the form is submitted. If you call
|
|
1579
|
-
* `event.preventDefault()` then this form will not do anything.
|
|
1580
|
-
*/
|
|
1581
|
-
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
1582
|
-
}
|
|
1583
|
-
/**
|
|
1584
|
-
* Form props available to fetchers
|
|
1585
|
-
* @category Types
|
|
1586
|
-
*/
|
|
1587
|
-
interface FetcherFormProps extends SharedFormProps {
|
|
1588
|
-
}
|
|
1589
|
-
/**
|
|
1590
|
-
* Form props available to navigations
|
|
1591
|
-
* @category Types
|
|
1592
|
-
*/
|
|
1593
|
-
interface FormProps extends SharedFormProps {
|
|
1594
|
-
discover?: DiscoverBehavior;
|
|
1595
|
-
/**
|
|
1596
|
-
* Indicates a specific fetcherKey to use when using `navigate={false}` so you
|
|
1597
|
-
* can pick up the fetcher's state in a different component in a {@link
|
|
1598
|
-
* useFetcher}.
|
|
1599
|
-
*/
|
|
1600
|
-
fetcherKey?: string;
|
|
1601
|
-
/**
|
|
1602
|
-
* Skips the navigation and uses a {@link useFetcher | fetcher} internally
|
|
1603
|
-
* when `false`. This is essentially a shorthand for `useFetcher()` +
|
|
1604
|
-
* `<fetcher.Form>` where you don't care about the resulting data in this
|
|
1605
|
-
* component.
|
|
1606
|
-
*/
|
|
1607
|
-
navigate?: boolean;
|
|
1608
|
-
/**
|
|
1609
|
-
* Forces a full document navigation instead of client side routing + data
|
|
1610
|
-
* fetch.
|
|
1611
|
-
*/
|
|
1612
|
-
reloadDocument?: boolean;
|
|
1613
|
-
/**
|
|
1614
|
-
* Replaces the current entry in the browser history stack when the form
|
|
1615
|
-
* navigates. Use this if you don't want the user to be able to click "back"
|
|
1616
|
-
* to the page with the form on it.
|
|
1617
|
-
*/
|
|
1618
|
-
replace?: boolean;
|
|
1619
|
-
/**
|
|
1620
|
-
* State object to add to the history stack entry for this navigation
|
|
1621
|
-
*/
|
|
1622
|
-
state?: any;
|
|
1623
|
-
/**
|
|
1624
|
-
* Enables a [View
|
|
1625
|
-
* Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
1626
|
-
* for this navigation. To apply specific styles during the transition see
|
|
1627
|
-
* {@link useViewTransitionState}.
|
|
1628
|
-
*/
|
|
1629
|
-
viewTransition?: boolean;
|
|
1630
|
-
}
|
|
1631
|
-
/**
|
|
1632
|
-
|
|
1633
|
-
A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) that submits data to actions via `fetch`, activating pending states in `useNavigation` which enables advanced user interfaces beyond a basic HTML form. After a form's action completes, all data on the page is automatically revalidated to keep the UI in sync with the data.
|
|
1634
|
-
|
|
1635
|
-
Because it uses the HTML form API, server rendered pages are interactive at a basic level before JavaScript loads. Instead of React Router managing the submission, the browser manages the submission as well as the pending states (like the spinning favicon). After JavaScript loads, React Router takes over enabling web application user experiences.
|
|
1636
|
-
|
|
1637
|
-
Form is most useful for submissions that should also change the URL or otherwise add an entry to the browser history stack. For forms that shouldn't manipulate the browser history stack, use [`<fetcher.Form>`][fetcher_form].
|
|
1638
|
-
|
|
1639
|
-
```tsx
|
|
1640
|
-
import { Form } from "react-router";
|
|
1641
|
-
|
|
1642
|
-
function NewEvent() {
|
|
1643
|
-
return (
|
|
1644
|
-
<Form action="/events" method="post">
|
|
1645
|
-
<input name="title" type="text" />
|
|
1646
|
-
<input name="description" type="text" />
|
|
1647
|
-
</Form>
|
|
1648
|
-
)
|
|
1649
|
-
}
|
|
1650
|
-
```
|
|
1651
|
-
|
|
1652
|
-
@category Components
|
|
1653
|
-
*/
|
|
1654
|
-
declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
|
|
1655
|
-
type ScrollRestorationProps = ScriptsProps & {
|
|
1656
|
-
/**
|
|
1657
|
-
Defines the key used to restore scroll positions.
|
|
1658
|
-
|
|
1659
|
-
```tsx
|
|
1660
|
-
<ScrollRestoration
|
|
1661
|
-
getKey={(location, matches) => {
|
|
1662
|
-
// default behavior
|
|
1663
|
-
return location.key
|
|
1664
|
-
}}
|
|
1665
|
-
/>
|
|
1666
|
-
```
|
|
1667
|
-
*/
|
|
1668
|
-
getKey?: GetScrollRestorationKeyFunction;
|
|
1669
|
-
storageKey?: string;
|
|
1670
|
-
};
|
|
1671
|
-
/**
|
|
1672
|
-
Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
|
|
177
|
+
* Returns the element for the child route at this level of the route
|
|
178
|
+
* hierarchy. Used internally by `<Outlet>` to render child routes.
|
|
179
|
+
*
|
|
180
|
+
* @category Hooks
|
|
181
|
+
*/
|
|
182
|
+
declare function useOutlet(context?: unknown): React.ReactElement | null;
|
|
183
|
+
/**
|
|
184
|
+
Returns an object of key/value pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
|
|
1673
185
|
|
|
1674
186
|
```tsx
|
|
1675
|
-
import {
|
|
187
|
+
import { useParams } from "react-router"
|
|
1676
188
|
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
<body>
|
|
1681
|
-
<ScrollRestoration />
|
|
1682
|
-
<Scripts />
|
|
1683
|
-
</body>
|
|
1684
|
-
</html>
|
|
1685
|
-
);
|
|
189
|
+
function SomeComponent() {
|
|
190
|
+
let params = useParams()
|
|
191
|
+
params.postId
|
|
1686
192
|
}
|
|
1687
193
|
```
|
|
1688
194
|
|
|
1689
|
-
|
|
195
|
+
Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
|
|
196
|
+
|
|
197
|
+
@category Hooks
|
|
198
|
+
*/
|
|
199
|
+
declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
|
|
200
|
+
ParamsOrKey
|
|
201
|
+
] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>;
|
|
202
|
+
/**
|
|
203
|
+
Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
|
|
1690
204
|
|
|
1691
205
|
```tsx
|
|
1692
|
-
|
|
206
|
+
import { useResolvedPath } from "react-router"
|
|
207
|
+
|
|
208
|
+
function SomeComponent() {
|
|
209
|
+
// if the user is at /dashboard/profile
|
|
210
|
+
let path = useResolvedPath("../accounts")
|
|
211
|
+
path.pathname // "/dashboard/accounts"
|
|
212
|
+
path.search // ""
|
|
213
|
+
path.hash // ""
|
|
214
|
+
}
|
|
1693
215
|
```
|
|
1694
216
|
|
|
1695
|
-
@category
|
|
1696
|
-
*/
|
|
1697
|
-
declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
|
|
1698
|
-
declare namespace ScrollRestoration {
|
|
1699
|
-
var displayName: string;
|
|
1700
|
-
}
|
|
1701
|
-
/**
|
|
1702
|
-
* Handles the click behavior for router `<Link>` components. This is useful if
|
|
1703
|
-
* you need to create custom `<Link>` components with the same click behavior we
|
|
1704
|
-
* use in our exported `<Link>`.
|
|
1705
|
-
*
|
|
1706
|
-
* @category Hooks
|
|
217
|
+
@category Hooks
|
|
1707
218
|
*/
|
|
1708
|
-
declare function
|
|
1709
|
-
target?: React.HTMLAttributeAnchorTarget;
|
|
1710
|
-
replace?: boolean;
|
|
1711
|
-
state?: any;
|
|
1712
|
-
preventScrollReset?: boolean;
|
|
219
|
+
declare function useResolvedPath(to: To, { relative }?: {
|
|
1713
220
|
relative?: RelativeRoutingType;
|
|
1714
|
-
|
|
1715
|
-
}): (event: React.MouseEvent<E, MouseEvent>) => void;
|
|
221
|
+
}): Path;
|
|
1716
222
|
/**
|
|
1717
|
-
|
|
223
|
+
Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
|
|
224
|
+
|
|
225
|
+
The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
|
|
1718
226
|
|
|
1719
227
|
```tsx
|
|
1720
|
-
import
|
|
228
|
+
import * as React from "react";
|
|
229
|
+
import { useRoutes } from "react-router";
|
|
1721
230
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
231
|
+
function App() {
|
|
232
|
+
let element = useRoutes([
|
|
233
|
+
{
|
|
234
|
+
path: "/",
|
|
235
|
+
element: <Dashboard />,
|
|
236
|
+
children: [
|
|
237
|
+
{
|
|
238
|
+
path: "messages",
|
|
239
|
+
element: <DashboardMessages />,
|
|
240
|
+
},
|
|
241
|
+
{ path: "tasks", element: <DashboardTasks /> },
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
{ path: "team", element: <AboutPage /> },
|
|
245
|
+
]);
|
|
246
|
+
|
|
247
|
+
return element;
|
|
1725
248
|
}
|
|
1726
249
|
```
|
|
1727
250
|
|
|
1728
251
|
@category Hooks
|
|
1729
252
|
*/
|
|
1730
|
-
declare function
|
|
253
|
+
declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
|
|
1731
254
|
/**
|
|
1732
|
-
|
|
255
|
+
Returns the current navigation, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read FormData from a form navigation.
|
|
1733
256
|
|
|
1734
257
|
```tsx
|
|
1735
|
-
|
|
1736
|
-
onClick={() => {
|
|
1737
|
-
const params = new URLSearchParams();
|
|
1738
|
-
params.set("someKey", "someValue");
|
|
1739
|
-
setSearchParams(params, {
|
|
1740
|
-
preventScrollReset: true,
|
|
1741
|
-
});
|
|
1742
|
-
}}
|
|
1743
|
-
/>
|
|
1744
|
-
```
|
|
1745
|
-
|
|
1746
|
-
It also supports a function for setting new search params.
|
|
258
|
+
import { useNavigation } from "react-router"
|
|
1747
259
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
});
|
|
1755
|
-
}}
|
|
1756
|
-
/>
|
|
260
|
+
function SomeComponent() {
|
|
261
|
+
let navigation = useNavigation();
|
|
262
|
+
navigation.state
|
|
263
|
+
navigation.formData
|
|
264
|
+
// etc.
|
|
265
|
+
}
|
|
1757
266
|
```
|
|
267
|
+
|
|
268
|
+
@category Hooks
|
|
1758
269
|
*/
|
|
1759
|
-
|
|
270
|
+
declare function useNavigation(): Navigation;
|
|
1760
271
|
/**
|
|
1761
|
-
|
|
1762
|
-
*/
|
|
1763
|
-
interface SubmitFunction {
|
|
1764
|
-
(
|
|
1765
|
-
/**
|
|
1766
|
-
Can be multiple types of elements and objects
|
|
1767
|
-
|
|
1768
|
-
**`HTMLFormElement`**
|
|
1769
|
-
|
|
1770
|
-
```tsx
|
|
1771
|
-
<Form
|
|
1772
|
-
onSubmit={(event) => {
|
|
1773
|
-
submit(event.currentTarget);
|
|
1774
|
-
}}
|
|
1775
|
-
/>
|
|
1776
|
-
```
|
|
272
|
+
Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
|
|
1777
273
|
|
|
1778
|
-
|
|
274
|
+
```tsx
|
|
275
|
+
import { useRevalidator } from "react-router";
|
|
1779
276
|
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
formData.append("myKey", "myValue");
|
|
1783
|
-
submit(formData, { method: "post" });
|
|
1784
|
-
```
|
|
277
|
+
function WindowFocusRevalidator() {
|
|
278
|
+
const revalidator = useRevalidator();
|
|
1785
279
|
|
|
1786
|
-
|
|
280
|
+
useFakeWindowFocus(() => {
|
|
281
|
+
revalidator.revalidate();
|
|
282
|
+
});
|
|
1787
283
|
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
284
|
+
return (
|
|
285
|
+
<div hidden={revalidator.state === "idle"}>
|
|
286
|
+
Revalidating...
|
|
287
|
+
</div>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
1791
291
|
|
|
1792
|
-
|
|
292
|
+
Note that page data is already revalidated automatically after actions. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
|
|
1793
293
|
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
*/
|
|
1801
|
-
target: SubmitTarget,
|
|
1802
|
-
/**
|
|
1803
|
-
* Options that override the `<form>`'s own attributes. Required when
|
|
1804
|
-
* submitting arbitrary data without a backing `<form>`.
|
|
1805
|
-
*/
|
|
1806
|
-
options?: SubmitOptions): Promise<void>;
|
|
1807
|
-
}
|
|
294
|
+
@category Hooks
|
|
295
|
+
*/
|
|
296
|
+
declare function useRevalidator(): {
|
|
297
|
+
revalidate(): Promise<void>;
|
|
298
|
+
state: RevalidationState;
|
|
299
|
+
};
|
|
1808
300
|
/**
|
|
1809
|
-
*
|
|
301
|
+
* Returns the active route matches, useful for accessing loaderData for
|
|
302
|
+
* parent/child routes or the route "handle" property
|
|
303
|
+
*
|
|
304
|
+
* @category Hooks
|
|
1810
305
|
*/
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
Can be multiple types of elements and objects
|
|
306
|
+
declare function useMatches(): UIMatch[];
|
|
307
|
+
/**
|
|
308
|
+
Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
|
|
1815
309
|
|
|
1816
|
-
|
|
310
|
+
```tsx
|
|
311
|
+
import { useLoaderData } from "react-router"
|
|
1817
312
|
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
fetcher.submit(event.currentTarget);
|
|
1822
|
-
}}
|
|
1823
|
-
/>
|
|
1824
|
-
```
|
|
313
|
+
export async function loader() {
|
|
314
|
+
return await fakeDb.invoices.findAll();
|
|
315
|
+
}
|
|
1825
316
|
|
|
1826
|
-
|
|
317
|
+
export default function Invoices() {
|
|
318
|
+
let invoices = useLoaderData<typeof loader>();
|
|
319
|
+
// ...
|
|
320
|
+
}
|
|
321
|
+
```
|
|
1827
322
|
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
323
|
+
@category Hooks
|
|
324
|
+
*/
|
|
325
|
+
declare function useLoaderData<T = any>(): SerializeFrom<T>;
|
|
326
|
+
/**
|
|
327
|
+
Returns the loader data for a given route by route ID.
|
|
1833
328
|
|
|
1834
|
-
|
|
329
|
+
```tsx
|
|
330
|
+
import { useRouteLoaderData } from "react-router";
|
|
1835
331
|
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
332
|
+
function SomeComponent() {
|
|
333
|
+
const { user } = useRouteLoaderData("root");
|
|
334
|
+
}
|
|
335
|
+
```
|
|
1839
336
|
|
|
1840
|
-
|
|
337
|
+
Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
|
|
1841
338
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
```
|
|
339
|
+
| Route Filename | Route ID |
|
|
340
|
+
| -------------------------- | -------------------- |
|
|
341
|
+
| `app/root.tsx` | `"root"` |
|
|
342
|
+
| `app/routes/teams.tsx` | `"routes/teams"` |
|
|
343
|
+
| `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
|
|
1848
344
|
|
|
1849
|
-
|
|
1850
|
-
target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
|
|
1851
|
-
}
|
|
1852
|
-
/**
|
|
1853
|
-
The imperative version of {@link Form | `<Form>`} that lets you submit a form from code instead of a user interaction.
|
|
345
|
+
If you created an ID manually, you can use that instead:
|
|
1854
346
|
|
|
1855
347
|
```tsx
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
function SomeComponent() {
|
|
1859
|
-
const submit = useSubmit();
|
|
1860
|
-
return (
|
|
1861
|
-
<Form
|
|
1862
|
-
onChange={(event) => {
|
|
1863
|
-
submit(event.currentTarget);
|
|
1864
|
-
}}
|
|
1865
|
-
/>
|
|
1866
|
-
);
|
|
1867
|
-
}
|
|
348
|
+
route("/", "containers/app.tsx", { id: "app" }})
|
|
1868
349
|
```
|
|
1869
350
|
|
|
1870
351
|
@category Hooks
|
|
1871
352
|
*/
|
|
1872
|
-
declare function
|
|
353
|
+
declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
|
|
1873
354
|
/**
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
This is used internally by {@link Form} resolve the action to the closest route, but can be used generically as well.
|
|
355
|
+
Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
|
|
1877
356
|
|
|
1878
357
|
```tsx
|
|
1879
|
-
import {
|
|
358
|
+
import { Form, useActionData } from "react-router"
|
|
1880
359
|
|
|
1881
|
-
function
|
|
1882
|
-
|
|
1883
|
-
|
|
360
|
+
export async function action({ request }) {
|
|
361
|
+
const body = await request.formData()
|
|
362
|
+
const name = body.get("visitorsName")
|
|
363
|
+
return { message: `Hello, ${name}` }
|
|
364
|
+
}
|
|
1884
365
|
|
|
1885
|
-
|
|
1886
|
-
|
|
366
|
+
export default function Invoices() {
|
|
367
|
+
const data = useActionData()
|
|
368
|
+
return (
|
|
369
|
+
<Form method="post">
|
|
370
|
+
<input type="text" name="visitorsName" />
|
|
371
|
+
{data ? data.message : "Waiting..."}
|
|
372
|
+
</Form>
|
|
373
|
+
)
|
|
1887
374
|
}
|
|
1888
375
|
```
|
|
1889
376
|
|
|
1890
377
|
@category Hooks
|
|
1891
378
|
*/
|
|
1892
|
-
declare function
|
|
1893
|
-
/**
|
|
1894
|
-
* The action to append to the closest route URL.
|
|
1895
|
-
*/
|
|
1896
|
-
action?: string, { relative }?: {
|
|
1897
|
-
relative?: RelativeRoutingType;
|
|
1898
|
-
}): string;
|
|
1899
|
-
/**
|
|
1900
|
-
The return value of `useFetcher` that keeps track of the state of a fetcher.
|
|
1901
|
-
|
|
1902
|
-
```tsx
|
|
1903
|
-
let fetcher = useFetcher();
|
|
1904
|
-
```
|
|
1905
|
-
*/
|
|
1906
|
-
type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
1907
|
-
/**
|
|
1908
|
-
Just like {@link Form} except it doesn't cause a navigation.
|
|
1909
|
-
|
|
1910
|
-
```tsx
|
|
1911
|
-
function SomeComponent() {
|
|
1912
|
-
const fetcher = useFetcher()
|
|
1913
|
-
return (
|
|
1914
|
-
<fetcher.Form method="post" action="/some/route">
|
|
1915
|
-
<input type="text" />
|
|
1916
|
-
</fetcher.Form>
|
|
1917
|
-
)
|
|
1918
|
-
}
|
|
1919
|
-
```
|
|
1920
|
-
*/
|
|
1921
|
-
Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
|
|
1922
|
-
/**
|
|
1923
|
-
Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
|
|
1924
|
-
|
|
1925
|
-
The `formData` can be multiple types:
|
|
1926
|
-
|
|
1927
|
-
- [`FormData`][form_data] - A `FormData` instance.
|
|
1928
|
-
- [`HTMLFormElement`][html_form_element] - A [`<form>`][form_element] DOM element.
|
|
1929
|
-
- `Object` - An object of key/value pairs that will be converted to a `FormData` instance by default. You can pass a more complex object and serialize it as JSON by specifying `encType: "application/json"`. See [`useSubmit`][use-submit] for more details.
|
|
1930
|
-
|
|
1931
|
-
If the method is `GET`, then the route [`loader`][loader] is being called and with the `formData` serialized to the url as [`URLSearchParams`][url_search_params]. If `DELETE`, `PATCH`, `POST`, or `PUT`, then the route [`action`][action] is being called with `formData` as the body.
|
|
1932
|
-
|
|
1933
|
-
```tsx
|
|
1934
|
-
// Submit a FormData instance (GET request)
|
|
1935
|
-
const formData = new FormData();
|
|
1936
|
-
fetcher.submit(formData);
|
|
1937
|
-
|
|
1938
|
-
// Submit the HTML form element
|
|
1939
|
-
fetcher.submit(event.currentTarget.form, {
|
|
1940
|
-
method: "POST",
|
|
1941
|
-
});
|
|
1942
|
-
|
|
1943
|
-
// Submit key/value JSON as a FormData instance
|
|
1944
|
-
fetcher.submit(
|
|
1945
|
-
{ serialized: "values" },
|
|
1946
|
-
{ method: "POST" }
|
|
1947
|
-
);
|
|
1948
|
-
|
|
1949
|
-
// Submit raw JSON
|
|
1950
|
-
fetcher.submit(
|
|
1951
|
-
{
|
|
1952
|
-
deeply: {
|
|
1953
|
-
nested: {
|
|
1954
|
-
json: "values",
|
|
1955
|
-
},
|
|
1956
|
-
},
|
|
1957
|
-
},
|
|
1958
|
-
{
|
|
1959
|
-
method: "POST",
|
|
1960
|
-
encType: "application/json",
|
|
1961
|
-
}
|
|
1962
|
-
);
|
|
1963
|
-
```
|
|
1964
|
-
*/
|
|
1965
|
-
submit: FetcherSubmitFunction;
|
|
1966
|
-
/**
|
|
1967
|
-
Loads data from a route. Useful for loading data imperatively inside of user events outside of a normal button or form, like a combobox or search input.
|
|
1968
|
-
|
|
1969
|
-
```tsx
|
|
1970
|
-
let fetcher = useFetcher()
|
|
1971
|
-
|
|
1972
|
-
<input onChange={e => {
|
|
1973
|
-
fetcher.load(`/search?q=${e.target.value}`)
|
|
1974
|
-
}} />
|
|
1975
|
-
```
|
|
1976
|
-
*/
|
|
1977
|
-
load: (href: string, opts?: {
|
|
1978
|
-
/**
|
|
1979
|
-
* Wraps the initial state update for this `fetcher.load` in a
|
|
1980
|
-
* `ReactDOM.flushSync` call instead of the default `React.startTransition`.
|
|
1981
|
-
* This allows you to perform synchronous DOM actions immediately after the
|
|
1982
|
-
* update is flushed to the DOM.
|
|
1983
|
-
*/
|
|
1984
|
-
flushSync?: boolean;
|
|
1985
|
-
}) => Promise<void>;
|
|
1986
|
-
};
|
|
379
|
+
declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
|
|
1987
380
|
/**
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
Fetchers track their own, independent state and can be used to load data, submit forms, and generally interact with loaders and actions.
|
|
381
|
+
Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
|
|
1991
382
|
|
|
1992
383
|
```tsx
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
let fetcher = useFetcher()
|
|
1997
|
-
|
|
1998
|
-
// states are available on the fetcher
|
|
1999
|
-
fetcher.state // "idle" | "loading" | "submitting"
|
|
2000
|
-
fetcher.data // the data returned from the action or loader
|
|
2001
|
-
|
|
2002
|
-
// render a form
|
|
2003
|
-
<fetcher.Form method="post" />
|
|
2004
|
-
|
|
2005
|
-
// load data
|
|
2006
|
-
fetcher.load("/some/route")
|
|
2007
|
-
|
|
2008
|
-
// submit data
|
|
2009
|
-
fetcher.submit(someFormRef, { method: "post" })
|
|
2010
|
-
fetcher.submit(someData, {
|
|
2011
|
-
method: "post",
|
|
2012
|
-
encType: "application/json"
|
|
2013
|
-
})
|
|
384
|
+
export function ErrorBoundary() {
|
|
385
|
+
const error = useRouteError();
|
|
386
|
+
return <div>{error.message}</div>;
|
|
2014
387
|
}
|
|
2015
388
|
```
|
|
2016
389
|
|
|
2017
390
|
@category Hooks
|
|
2018
391
|
*/
|
|
2019
|
-
declare function
|
|
2020
|
-
/**
|
|
2021
|
-
By default, `useFetcher` generate a unique fetcher scoped to that component. If you want to identify a fetcher with your own key such that you can access it from elsewhere in your app, you can do that with the `key` option:
|
|
2022
|
-
|
|
2023
|
-
```tsx
|
|
2024
|
-
function SomeComp() {
|
|
2025
|
-
let fetcher = useFetcher({ key: "my-key" })
|
|
2026
|
-
// ...
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
// Somewhere else
|
|
2030
|
-
function AnotherComp() {
|
|
2031
|
-
// this will be the same fetcher, sharing the state across the app
|
|
2032
|
-
let fetcher = useFetcher({ key: "my-key" });
|
|
2033
|
-
// ...
|
|
2034
|
-
}
|
|
2035
|
-
```
|
|
2036
|
-
*/
|
|
2037
|
-
key?: string;
|
|
2038
|
-
}): FetcherWithComponents<SerializeFrom<T>>;
|
|
392
|
+
declare function useRouteError(): unknown;
|
|
2039
393
|
/**
|
|
2040
|
-
Returns
|
|
394
|
+
Returns the resolved promise value from the closest {@link Await | `<Await>`}.
|
|
2041
395
|
|
|
2042
396
|
```tsx
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
function SomeComponent() {
|
|
2046
|
-
const fetchers = useFetchers();
|
|
2047
|
-
fetchers[0].formData; // FormData
|
|
2048
|
-
fetchers[0].state; // etc.
|
|
397
|
+
function SomeDescendant() {
|
|
398
|
+
const value = useAsyncValue();
|
|
2049
399
|
// ...
|
|
2050
400
|
}
|
|
401
|
+
|
|
402
|
+
// somewhere in your app
|
|
403
|
+
<Await resolve={somePromise}>
|
|
404
|
+
<SomeDescendant />
|
|
405
|
+
</Await>
|
|
2051
406
|
```
|
|
2052
407
|
|
|
2053
408
|
@category Hooks
|
|
2054
409
|
*/
|
|
2055
|
-
declare function
|
|
2056
|
-
key: string;
|
|
2057
|
-
})[];
|
|
2058
|
-
/**
|
|
2059
|
-
* When rendered inside a RouterProvider, will restore scroll positions on navigations
|
|
2060
|
-
*/
|
|
2061
|
-
declare function useScrollRestoration({ getKey, storageKey, }?: {
|
|
2062
|
-
getKey?: GetScrollRestorationKeyFunction;
|
|
2063
|
-
storageKey?: string;
|
|
2064
|
-
}): void;
|
|
2065
|
-
/**
|
|
2066
|
-
* Setup a callback to be fired on the window's `beforeunload` event.
|
|
2067
|
-
*
|
|
2068
|
-
* @category Hooks
|
|
2069
|
-
*/
|
|
2070
|
-
declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
|
|
2071
|
-
capture?: boolean;
|
|
2072
|
-
}): void;
|
|
410
|
+
declare function useAsyncValue(): unknown;
|
|
2073
411
|
/**
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
The `unstable_` flag will not be removed because this technique has a lot of rough edges and behaves very differently (and incorrectly sometimes) across browsers if users click addition back/forward navigations while the confirmation is open. Use at your own risk.
|
|
412
|
+
Returns the rejection value from the closest {@link Await | `<Await>`}.
|
|
2077
413
|
|
|
2078
414
|
```tsx
|
|
2079
|
-
|
|
2080
|
-
let [value, setValue] = React.useState("");
|
|
2081
|
-
|
|
2082
|
-
// Block navigating elsewhere when data has been entered into the input
|
|
2083
|
-
unstable_usePrompt({
|
|
2084
|
-
message: "Are you sure?",
|
|
2085
|
-
when: ({ currentLocation, nextLocation }) =>
|
|
2086
|
-
value !== "" &&
|
|
2087
|
-
currentLocation.pathname !== nextLocation.pathname,
|
|
2088
|
-
});
|
|
415
|
+
import { Await, useAsyncError } from "react-router"
|
|
2089
416
|
|
|
417
|
+
function ErrorElement() {
|
|
418
|
+
const error = useAsyncError();
|
|
2090
419
|
return (
|
|
2091
|
-
<
|
|
2092
|
-
<label>
|
|
2093
|
-
Enter some important data:
|
|
2094
|
-
<input
|
|
2095
|
-
name="data"
|
|
2096
|
-
value={value}
|
|
2097
|
-
onChange={(e) => setValue(e.target.value)}
|
|
2098
|
-
/>
|
|
2099
|
-
</label>
|
|
2100
|
-
<button type="submit">Save</button>
|
|
2101
|
-
</Form>
|
|
420
|
+
<p>Uh Oh, something went wrong! {error.message}</p>
|
|
2102
421
|
);
|
|
2103
422
|
}
|
|
423
|
+
|
|
424
|
+
// somewhere in your app
|
|
425
|
+
<Await
|
|
426
|
+
resolve={promiseThatRejects}
|
|
427
|
+
errorElement={<ErrorElement />}
|
|
428
|
+
/>
|
|
2104
429
|
```
|
|
2105
430
|
|
|
2106
431
|
@category Hooks
|
|
2107
|
-
@name unstable_usePrompt
|
|
2108
432
|
*/
|
|
2109
|
-
declare function
|
|
2110
|
-
when: boolean | BlockerFunction;
|
|
2111
|
-
message: string;
|
|
2112
|
-
}): void;
|
|
433
|
+
declare function useAsyncError(): unknown;
|
|
2113
434
|
/**
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
435
|
+
* Allow the application to block navigations within the SPA and present the
|
|
436
|
+
* user a confirmation dialog to confirm the navigation. Mostly used to avoid
|
|
437
|
+
* using half-filled form data. This does not handle hard-reloads or
|
|
438
|
+
* cross-origin navigations.
|
|
439
|
+
*
|
|
440
|
+
* @category Hooks
|
|
2118
441
|
*/
|
|
2119
|
-
declare function
|
|
2120
|
-
relative?: RelativeRoutingType;
|
|
2121
|
-
}): boolean;
|
|
442
|
+
declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
|
|
2122
443
|
|
|
2123
444
|
interface StaticRouterProps {
|
|
2124
445
|
basename?: string;
|
|
@@ -2134,7 +455,7 @@ interface StaticRouterProps {
|
|
|
2134
455
|
declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
|
|
2135
456
|
interface StaticRouterProviderProps {
|
|
2136
457
|
context: StaticHandlerContext;
|
|
2137
|
-
router: Router
|
|
458
|
+
router: Router;
|
|
2138
459
|
hydrate?: boolean;
|
|
2139
460
|
nonce?: string;
|
|
2140
461
|
}
|
|
@@ -2155,7 +476,7 @@ declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticH
|
|
|
2155
476
|
*/
|
|
2156
477
|
declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
|
|
2157
478
|
future?: Partial<FutureConfig$1>;
|
|
2158
|
-
}): Router
|
|
479
|
+
}): Router;
|
|
2159
480
|
|
|
2160
481
|
interface ServerRouterProps {
|
|
2161
482
|
context: EntryContext;
|
|
@@ -2294,7 +615,7 @@ interface SessionData {
|
|
|
2294
615
|
/**
|
|
2295
616
|
* Session persists data across HTTP requests.
|
|
2296
617
|
*
|
|
2297
|
-
* @see https://
|
|
618
|
+
* @see https://remix.run/utils/sessions#session-api
|
|
2298
619
|
*/
|
|
2299
620
|
interface Session<Data = SessionData, FlashData = Data> {
|
|
2300
621
|
/**
|
|
@@ -2344,13 +665,15 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
|
|
|
2344
665
|
*
|
|
2345
666
|
* Note: This function is typically not invoked directly by application code.
|
|
2346
667
|
* Instead, use a `SessionStorage` object's `getSession` method.
|
|
668
|
+
*
|
|
669
|
+
* @see https://remix.run/utils/sessions#createsession
|
|
2347
670
|
*/
|
|
2348
671
|
declare const createSession: CreateSessionFunction;
|
|
2349
672
|
type IsSessionFunction = (object: any) => object is Session;
|
|
2350
673
|
/**
|
|
2351
|
-
* Returns true if an object is a
|
|
674
|
+
* Returns true if an object is a Remix session.
|
|
2352
675
|
*
|
|
2353
|
-
* @see https://
|
|
676
|
+
* @see https://remix.run/utils/sessions#issession
|
|
2354
677
|
*/
|
|
2355
678
|
declare const isSession: IsSessionFunction;
|
|
2356
679
|
/**
|
|
@@ -2491,6 +814,11 @@ type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [
|
|
|
2491
814
|
*/
|
|
2492
815
|
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
|
2493
816
|
|
|
817
|
+
declare function routeRSCServerRequest(request: Request, requestServer: (request: Request) => Promise<Response>, decode: (body: ReadableStream<Uint8Array>) => Promise<ServerPayload>, renderHTML: (payload: ServerPayload) => ReadableStream<Uint8Array> | Promise<ReadableStream<Uint8Array>>): Promise<Response>;
|
|
818
|
+
declare function RSCStaticRouter({ payload }: {
|
|
819
|
+
payload: ServerPayload;
|
|
820
|
+
}): React.JSX.Element | null;
|
|
821
|
+
|
|
2494
822
|
declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
|
|
2495
823
|
|
|
2496
824
|
type RemixErrorBoundaryProps = React.PropsWithChildren<{
|
|
@@ -2514,24 +842,14 @@ declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps
|
|
|
2514
842
|
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
2515
843
|
}
|
|
2516
844
|
|
|
2517
|
-
declare global {
|
|
2518
|
-
interface Navigator {
|
|
2519
|
-
connection?: {
|
|
2520
|
-
saveData: boolean;
|
|
2521
|
-
};
|
|
2522
|
-
}
|
|
2523
|
-
}
|
|
2524
|
-
declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
|
|
2525
|
-
declare function useFogOFWarDiscovery(router: Router$1, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
|
|
2526
|
-
|
|
2527
845
|
declare function getHydrationData(state: {
|
|
2528
|
-
loaderData?: Router
|
|
2529
|
-
actionData?: Router
|
|
2530
|
-
errors?: Router
|
|
846
|
+
loaderData?: Router["state"]["loaderData"];
|
|
847
|
+
actionData?: Router["state"]["actionData"];
|
|
848
|
+
errors?: Router["state"]["errors"];
|
|
2531
849
|
}, routes: DataRouteObject[], getRouteInfo: (routeId: string) => {
|
|
2532
850
|
clientLoader: ClientLoaderFunction | undefined;
|
|
2533
851
|
hasLoader: boolean;
|
|
2534
852
|
hasHydrateFallback: boolean;
|
|
2535
853
|
}, location: Path, basename: string | undefined, isSpaMode: boolean): HydrationState;
|
|
2536
854
|
|
|
2537
|
-
export { ActionFunction, ActionFunctionArgs, AppLoadContext,
|
|
855
|
+
export { ActionFunction, ActionFunctionArgs, AppLoadContext, Blocker, BlockerFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, DataRouteObject, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params$1 as Params, Path, PathMatch, PathPattern, RSCStaticRouter, type Register, RelativeRoutingType, type RequestHandler, RevalidationState, RouteObject, RouterState, type RoutesTestStubProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, MiddlewareEnabled as UNSAFE_MiddlewareEnabled, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, routeRSCServerRequest, unstable_InitialContext, unstable_RouterContextProvider, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
|