react-router 7.0.0-pre.2 → 7.0.0-pre.3
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 +2 -0
- package/dist/chunk-3AAHPOYG.mjs +9617 -0
- package/dist/dom-export.d.mts +13 -0
- package/dist/dom-export.d.ts +13 -3
- package/dist/dom-export.js +5502 -0
- package/dist/dom-export.mjs +112 -126
- package/dist/{lib/dom/lib.d.ts → fog-of-war-BijhfqFM.d.ts} +699 -45
- package/dist/fog-of-war-Bz_EDtxF.d.mts +1595 -0
- package/dist/index.d.mts +839 -0
- package/dist/index.d.ts +839 -73
- package/dist/index.js +9763 -0
- package/dist/index.mjs +225 -12689
- package/dist/lib/types.d.mts +2 -0
- package/dist/lib/types.d.ts +2 -83
- package/dist/lib/types.js +28 -0
- package/dist/lib/types.mjs +1 -1
- package/dist/types-BlYP8xpH.d.mts +1620 -0
- package/dist/types-BlYP8xpH.d.ts +1620 -0
- package/package.json +52 -12
- package/dist/dom-export.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/lib/components.d.ts +0 -372
- package/dist/lib/context.d.ts +0 -115
- package/dist/lib/dom/dom.d.ts +0 -123
- package/dist/lib/dom/global.d.ts +0 -40
- package/dist/lib/dom/server.d.ts +0 -41
- package/dist/lib/dom/ssr/components.d.ts +0 -122
- package/dist/lib/dom/ssr/data.d.ts +0 -2
- package/dist/lib/dom/ssr/entry.d.ts +0 -48
- package/dist/lib/dom/ssr/errorBoundaries.d.ts +0 -36
- package/dist/lib/dom/ssr/errors.d.ts +0 -2
- package/dist/lib/dom/ssr/fallback.d.ts +0 -2
- package/dist/lib/dom/ssr/fog-of-war.d.ts +0 -28
- package/dist/lib/dom/ssr/invariant.d.ts +0 -2
- package/dist/lib/dom/ssr/links.d.ts +0 -25
- package/dist/lib/dom/ssr/markup.d.ts +0 -5
- package/dist/lib/dom/ssr/routeModules.d.ts +0 -183
- package/dist/lib/dom/ssr/routes-test-stub.d.ts +0 -59
- package/dist/lib/dom/ssr/routes.d.ts +0 -29
- package/dist/lib/dom/ssr/server.d.ts +0 -16
- package/dist/lib/dom/ssr/single-fetch.d.ts +0 -37
- package/dist/lib/dom-export/dom-router-provider.d.ts +0 -5
- package/dist/lib/dom-export/hydrated-router.d.ts +0 -5
- package/dist/lib/dom-export.d.ts +0 -3
- package/dist/lib/hooks.d.ts +0 -411
- package/dist/lib/router/history.d.ts +0 -253
- package/dist/lib/router/links.d.ts +0 -104
- package/dist/lib/router/router.d.ts +0 -544
- package/dist/lib/router/utils.d.ts +0 -497
- package/dist/lib/server-runtime/build.d.ts +0 -38
- package/dist/lib/server-runtime/cookies.d.ts +0 -62
- package/dist/lib/server-runtime/crypto.d.ts +0 -2
- package/dist/lib/server-runtime/data.d.ts +0 -11
- package/dist/lib/server-runtime/dev.d.ts +0 -8
- package/dist/lib/server-runtime/entry.d.ts +0 -3
- package/dist/lib/server-runtime/errors.d.ts +0 -51
- package/dist/lib/server-runtime/headers.d.ts +0 -3
- package/dist/lib/server-runtime/invariant.d.ts +0 -2
- package/dist/lib/server-runtime/markup.d.ts +0 -1
- package/dist/lib/server-runtime/mode.d.ts +0 -9
- package/dist/lib/server-runtime/routeMatching.d.ts +0 -8
- package/dist/lib/server-runtime/routeModules.d.ts +0 -40
- package/dist/lib/server-runtime/routes.d.ts +0 -11
- package/dist/lib/server-runtime/server.d.ts +0 -5
- package/dist/lib/server-runtime/serverHandoff.d.ts +0 -11
- package/dist/lib/server-runtime/sessions/cookieStorage.d.ts +0 -19
- package/dist/lib/server-runtime/sessions/memoryStorage.d.ts +0 -17
- package/dist/lib/server-runtime/sessions.d.ts +0 -140
- package/dist/lib/server-runtime/single-fetch.d.ts +0 -30
- package/dist/lib/server-runtime/typecheck.d.ts +0 -4
- package/dist/lib/server-runtime/warnings.d.ts +0 -1
- package/dist/main-dom-export.js +0 -19
- package/dist/main.js +0 -19
- package/dist/react-router-dom.development.js +0 -199
- package/dist/react-router-dom.development.js.map +0 -1
- package/dist/react-router-dom.production.min.js +0 -12
- package/dist/react-router-dom.production.min.js.map +0 -1
- package/dist/react-router.development.js +0 -12528
- package/dist/react-router.development.js.map +0 -1
- package/dist/react-router.production.min.js +0 -12
- package/dist/react-router.production.min.js.map +0 -1
- package/dist/umd/react-router-dom.development.js +0 -241
- package/dist/umd/react-router-dom.development.js.map +0 -1
- package/dist/umd/react-router-dom.production.min.js +0 -12
- package/dist/umd/react-router-dom.production.min.js.map +0 -1
- package/dist/umd/react-router.development.js +0 -12834
- package/dist/umd/react-router.development.js.map +0 -1
- package/dist/umd/react-router.production.min.js +0 -12
- package/dist/umd/react-router.production.min.js.map +0 -1
|
@@ -1,15 +1,658 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { o as RouteObject, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, an as PatchRoutesOnNavigationFunction, a as Router$1, T as To, h as RelativeRoutingType, w as NonIndexRouteObject, a1 as LazyRouteFunction, v as IndexRouteObject, i as Location, j as Action, am as Navigator, ap as RouteMatch, s as StaticHandlerContext, d as RouteManifest, R as RouteModules, al as DataRouteObject, aI as RouteModule, a0 as HTMLFormMethod, _ as FormEncType, au as PageLinkDescriptor, aJ as History, y as GetScrollRestorationKeyFunction, N as NavigateOptions, z as Fetcher, S as SerializeFrom, B as BlockerFunction } from './types-BlYP8xpH.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
|
|
8
|
+
hasErrorBoundary: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @category Routers
|
|
12
|
+
*/
|
|
13
|
+
declare function createMemoryRouter(routes: RouteObject[], opts?: {
|
|
14
|
+
basename?: string;
|
|
15
|
+
future?: Partial<FutureConfig$1>;
|
|
16
|
+
hydrationData?: HydrationState;
|
|
17
|
+
initialEntries?: InitialEntry[];
|
|
18
|
+
initialIndex?: number;
|
|
19
|
+
dataStrategy?: DataStrategyFunction;
|
|
20
|
+
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
|
21
|
+
}): Router$1;
|
|
22
|
+
interface RouterProviderProps {
|
|
23
|
+
router: Router$1;
|
|
24
|
+
flushSync?: (fn: () => unknown) => undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Given a Remix Router instance, render the appropriate UI
|
|
28
|
+
*/
|
|
29
|
+
declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
|
|
30
|
+
/**
|
|
31
|
+
* @category Types
|
|
32
|
+
*/
|
|
33
|
+
interface MemoryRouterProps {
|
|
34
|
+
basename?: string;
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
initialEntries?: InitialEntry[];
|
|
37
|
+
initialIndex?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A `<Router>` that stores all entries in memory.
|
|
41
|
+
*
|
|
42
|
+
* @category Router Components
|
|
43
|
+
*/
|
|
44
|
+
declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
|
|
45
|
+
/**
|
|
46
|
+
* @category Types
|
|
47
|
+
*/
|
|
48
|
+
interface NavigateProps {
|
|
49
|
+
to: To;
|
|
50
|
+
replace?: boolean;
|
|
51
|
+
state?: any;
|
|
52
|
+
relative?: RelativeRoutingType;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A component-based version of {@link useNavigate} to use in a [`React.Component
|
|
56
|
+
* Class`](https://reactjs.org/docs/react-component.html) where hooks are not
|
|
57
|
+
* able to be used.
|
|
58
|
+
*
|
|
59
|
+
* It's recommended to avoid using this component in favor of {@link useNavigate}
|
|
60
|
+
*
|
|
61
|
+
* @category Components
|
|
62
|
+
*/
|
|
63
|
+
declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
|
|
64
|
+
/**
|
|
65
|
+
* @category Types
|
|
66
|
+
*/
|
|
67
|
+
interface OutletProps {
|
|
68
|
+
/**
|
|
69
|
+
Provides a context value to the element tree below the outlet. Use when the parent route needs to provide values to child routes.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<Outlet context={myContextValue} />
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Access the context with {@link useOutletContext}.
|
|
76
|
+
*/
|
|
77
|
+
context?: unknown;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
Renders the matching child route of a parent route or nothing if no child route matches.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { Outlet } from "react-router"
|
|
84
|
+
|
|
85
|
+
export default function SomeParent() {
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
<h1>Parent Content</h1>
|
|
89
|
+
<Outlet />
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
@category Components
|
|
96
|
+
*/
|
|
97
|
+
declare function Outlet(props: OutletProps): React.ReactElement | null;
|
|
98
|
+
/**
|
|
99
|
+
* @category Types
|
|
100
|
+
*/
|
|
101
|
+
interface PathRouteProps {
|
|
102
|
+
caseSensitive?: NonIndexRouteObject["caseSensitive"];
|
|
103
|
+
path?: NonIndexRouteObject["path"];
|
|
104
|
+
id?: NonIndexRouteObject["id"];
|
|
105
|
+
lazy?: LazyRouteFunction<NonIndexRouteObject>;
|
|
106
|
+
loader?: NonIndexRouteObject["loader"];
|
|
107
|
+
action?: NonIndexRouteObject["action"];
|
|
108
|
+
hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
|
|
109
|
+
shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
|
|
110
|
+
handle?: NonIndexRouteObject["handle"];
|
|
111
|
+
index?: false;
|
|
112
|
+
children?: React.ReactNode;
|
|
113
|
+
element?: React.ReactNode | null;
|
|
114
|
+
hydrateFallbackElement?: React.ReactNode | null;
|
|
115
|
+
errorElement?: React.ReactNode | null;
|
|
116
|
+
Component?: React.ComponentType | null;
|
|
117
|
+
HydrateFallback?: React.ComponentType | null;
|
|
118
|
+
ErrorBoundary?: React.ComponentType | null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @category Types
|
|
122
|
+
*/
|
|
123
|
+
interface LayoutRouteProps extends PathRouteProps {
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @category Types
|
|
127
|
+
*/
|
|
128
|
+
interface IndexRouteProps {
|
|
129
|
+
caseSensitive?: IndexRouteObject["caseSensitive"];
|
|
130
|
+
path?: IndexRouteObject["path"];
|
|
131
|
+
id?: IndexRouteObject["id"];
|
|
132
|
+
lazy?: LazyRouteFunction<IndexRouteObject>;
|
|
133
|
+
loader?: IndexRouteObject["loader"];
|
|
134
|
+
action?: IndexRouteObject["action"];
|
|
135
|
+
hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
|
|
136
|
+
shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
|
|
137
|
+
handle?: IndexRouteObject["handle"];
|
|
138
|
+
index: true;
|
|
139
|
+
children?: undefined;
|
|
140
|
+
element?: React.ReactNode | null;
|
|
141
|
+
hydrateFallbackElement?: React.ReactNode | null;
|
|
142
|
+
errorElement?: React.ReactNode | null;
|
|
143
|
+
Component?: React.ComponentType | null;
|
|
144
|
+
HydrateFallback?: React.ComponentType | null;
|
|
145
|
+
ErrorBoundary?: React.ComponentType | null;
|
|
146
|
+
}
|
|
147
|
+
type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
|
|
148
|
+
/**
|
|
149
|
+
* Configures an element to render when a pattern matches the current location.
|
|
150
|
+
* It must be rendered within a {@link Routes} element. Note that these routes
|
|
151
|
+
* do not participate in data loading, actions, code splitting, or any other
|
|
152
|
+
* route module features.
|
|
153
|
+
*
|
|
154
|
+
* @category Components
|
|
155
|
+
*/
|
|
156
|
+
declare function Route$1(_props: RouteProps): React.ReactElement | null;
|
|
157
|
+
/**
|
|
158
|
+
* @category Types
|
|
159
|
+
*/
|
|
160
|
+
interface RouterProps {
|
|
161
|
+
basename?: string;
|
|
162
|
+
children?: React.ReactNode;
|
|
163
|
+
location: Partial<Location> | string;
|
|
164
|
+
navigationType?: Action;
|
|
165
|
+
navigator: Navigator;
|
|
166
|
+
static?: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Provides location context for the rest of the app.
|
|
170
|
+
*
|
|
171
|
+
* Note: You usually won't render a `<Router>` directly. Instead, you'll render a
|
|
172
|
+
* router that is more specific to your environment such as a `<BrowserRouter>`
|
|
173
|
+
* in web browsers or a `<StaticRouter>` for server rendering.
|
|
174
|
+
*
|
|
175
|
+
* @category Components
|
|
176
|
+
*/
|
|
177
|
+
declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
|
|
178
|
+
/**
|
|
179
|
+
* @category Types
|
|
180
|
+
*/
|
|
181
|
+
interface RoutesProps {
|
|
182
|
+
/**
|
|
183
|
+
* Nested {@link Route} elements
|
|
184
|
+
*/
|
|
185
|
+
children?: React.ReactNode;
|
|
186
|
+
/**
|
|
187
|
+
* The location to match against. Defaults to the current location.
|
|
188
|
+
*/
|
|
189
|
+
location?: Partial<Location> | string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
Renders a branch of {@link Route | `<Routes>`} that best matches the current
|
|
193
|
+
location. Note that these routes do not participate in data loading, actions,
|
|
194
|
+
code splitting, or any other route module features.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import { Routes, Route } from "react-router"
|
|
198
|
+
|
|
199
|
+
<Routes>
|
|
200
|
+
<Route index element={<StepOne />} />
|
|
201
|
+
<Route path="step-2" element={<StepTwo />} />
|
|
202
|
+
<Route path="step-3" element={<StepThree />}>
|
|
203
|
+
</Routes>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
@category Components
|
|
207
|
+
*/
|
|
208
|
+
declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
|
|
209
|
+
interface AwaitResolveRenderFunction<Resolve = any> {
|
|
210
|
+
(data: Awaited<Resolve>): React.ReactNode;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @category Types
|
|
214
|
+
*/
|
|
215
|
+
interface AwaitProps<Resolve> {
|
|
216
|
+
/**
|
|
217
|
+
When using a function, the resolved value is provided as the parameter.
|
|
218
|
+
|
|
219
|
+
```tsx [2]
|
|
220
|
+
<Await resolve={reviewsPromise}>
|
|
221
|
+
{(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
222
|
+
</Await>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
When using React elements, {@link useAsyncValue} will provide the
|
|
226
|
+
resolved value:
|
|
227
|
+
|
|
228
|
+
```tsx [2]
|
|
229
|
+
<Await resolve={reviewsPromise}>
|
|
230
|
+
<Reviews />
|
|
231
|
+
</Await>
|
|
232
|
+
|
|
233
|
+
function Reviews() {
|
|
234
|
+
const resolvedReviews = useAsyncValue()
|
|
235
|
+
return <div>...</div>
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
*/
|
|
239
|
+
children: React.ReactNode | AwaitResolveRenderFunction;
|
|
240
|
+
/**
|
|
241
|
+
The error element renders instead of the children when the promise rejects.
|
|
242
|
+
|
|
243
|
+
```tsx
|
|
244
|
+
<Await
|
|
245
|
+
errorElement={<div>Oops</div>}
|
|
246
|
+
resolve={reviewsPromise}
|
|
247
|
+
>
|
|
248
|
+
<Reviews />
|
|
249
|
+
</Await>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
To provide a more contextual error, you can use the {@link useAsyncError} in a
|
|
253
|
+
child component
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
<Await
|
|
257
|
+
errorElement={<ReviewsError />}
|
|
258
|
+
resolve={reviewsPromise}
|
|
259
|
+
>
|
|
260
|
+
<Reviews />
|
|
261
|
+
</Await>
|
|
262
|
+
|
|
263
|
+
function ReviewsError() {
|
|
264
|
+
const error = useAsyncError()
|
|
265
|
+
return <div>Error loading reviews: {error.message}</div>
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
If you do not provide an errorElement, the rejected value will bubble up to
|
|
270
|
+
the nearest route-level {@link NonIndexRouteObject#ErrorBoundary | ErrorBoundary} and be accessible
|
|
271
|
+
via {@link useRouteError} hook.
|
|
272
|
+
*/
|
|
273
|
+
errorElement?: React.ReactNode;
|
|
274
|
+
/**
|
|
275
|
+
Takes a promise returned from a {@link LoaderFunction | loader} value to be resolved and rendered.
|
|
276
|
+
|
|
277
|
+
```jsx
|
|
278
|
+
import { useLoaderData, Await } from "react-router"
|
|
279
|
+
|
|
280
|
+
export async function loader() {
|
|
281
|
+
let reviews = getReviews() // not awaited
|
|
282
|
+
let book = await getBook()
|
|
283
|
+
return {
|
|
284
|
+
book,
|
|
285
|
+
reviews, // this is a promise
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export default function Book() {
|
|
290
|
+
const {
|
|
291
|
+
book,
|
|
292
|
+
reviews, // this is the same promise
|
|
293
|
+
} = useLoaderData()
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<div>
|
|
297
|
+
<h1>{book.title}</h1>
|
|
298
|
+
<p>{book.description}</p>
|
|
299
|
+
<React.Suspense fallback={<ReviewsSkeleton />}>
|
|
300
|
+
<Await
|
|
301
|
+
// and is the promise we pass to Await
|
|
302
|
+
resolve={reviews}
|
|
303
|
+
>
|
|
304
|
+
<Reviews />
|
|
305
|
+
</Await>
|
|
306
|
+
</React.Suspense>
|
|
307
|
+
</div>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
*/
|
|
312
|
+
resolve: Resolve;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
Used to render promise values with automatic error handling.
|
|
316
|
+
|
|
317
|
+
```tsx
|
|
318
|
+
import { Await, useLoaderData } from "react-router";
|
|
319
|
+
|
|
320
|
+
export function loader() {
|
|
321
|
+
// not awaited
|
|
322
|
+
const reviews = getReviews()
|
|
323
|
+
// awaited (blocks the transition)
|
|
324
|
+
const book = await fetch("/api/book").then((res) => res.json())
|
|
325
|
+
return { book, reviews }
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function Book() {
|
|
329
|
+
const { book, reviews } = useLoaderData();
|
|
330
|
+
return (
|
|
331
|
+
<div>
|
|
332
|
+
<h1>{book.title}</h1>
|
|
333
|
+
<p>{book.description}</p>
|
|
334
|
+
<React.Suspense fallback={<ReviewsSkeleton />}>
|
|
335
|
+
<Await
|
|
336
|
+
resolve={reviews}
|
|
337
|
+
errorElement={
|
|
338
|
+
<div>Could not load reviews 😬</div>
|
|
339
|
+
}
|
|
340
|
+
children={(resolvedReviews) => (
|
|
341
|
+
<Reviews items={resolvedReviews} />
|
|
342
|
+
)}
|
|
343
|
+
/>
|
|
344
|
+
</React.Suspense>
|
|
345
|
+
</div>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**Note:** `<Await>` expects to be rendered inside of a `<React.Suspense>`
|
|
351
|
+
|
|
352
|
+
@category Components
|
|
353
|
+
|
|
354
|
+
*/
|
|
355
|
+
declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
|
|
356
|
+
/**
|
|
357
|
+
* Creates a route config from a React "children" object, which is usually
|
|
358
|
+
* either a `<Route>` element or an array of them. Used internally by
|
|
359
|
+
* `<Routes>` to create a route config from its children.
|
|
360
|
+
*
|
|
361
|
+
* @category Utils
|
|
362
|
+
*/
|
|
363
|
+
declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
|
|
364
|
+
/**
|
|
365
|
+
* Renders the result of `matchRoutes()` into a React element.
|
|
366
|
+
*
|
|
367
|
+
* @category Utils
|
|
368
|
+
*/
|
|
369
|
+
declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
|
|
370
|
+
|
|
371
|
+
type SerializedError = {
|
|
372
|
+
message: string;
|
|
373
|
+
stack?: string;
|
|
374
|
+
};
|
|
375
|
+
interface FrameworkContextObject {
|
|
376
|
+
manifest: AssetsManifest;
|
|
377
|
+
routeModules: RouteModules;
|
|
378
|
+
criticalCss?: string;
|
|
379
|
+
serverHandoffString?: string;
|
|
380
|
+
future: FutureConfig;
|
|
381
|
+
isSpaMode: boolean;
|
|
382
|
+
abortDelay?: number;
|
|
383
|
+
serializeError?(error: Error): SerializedError;
|
|
384
|
+
renderMeta?: {
|
|
385
|
+
didRenderScripts?: boolean;
|
|
386
|
+
streamCache?: Record<number, Promise<void> & {
|
|
387
|
+
result?: {
|
|
388
|
+
done: boolean;
|
|
389
|
+
value: string;
|
|
390
|
+
};
|
|
391
|
+
error?: unknown;
|
|
392
|
+
}>;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
interface EntryContext extends FrameworkContextObject {
|
|
396
|
+
staticHandlerContext: StaticHandlerContext;
|
|
397
|
+
serverHandoffStream?: ReadableStream<Uint8Array>;
|
|
398
|
+
}
|
|
399
|
+
interface FutureConfig {
|
|
400
|
+
}
|
|
401
|
+
interface AssetsManifest {
|
|
402
|
+
entry: {
|
|
403
|
+
imports: string[];
|
|
404
|
+
module: string;
|
|
405
|
+
};
|
|
406
|
+
routes: RouteManifest<EntryRoute>;
|
|
407
|
+
url: string;
|
|
408
|
+
version: string;
|
|
409
|
+
hmr?: {
|
|
410
|
+
timestamp?: number;
|
|
411
|
+
runtime: string;
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
interface Route {
|
|
416
|
+
index?: boolean;
|
|
417
|
+
caseSensitive?: boolean;
|
|
418
|
+
id: string;
|
|
419
|
+
parentId?: string;
|
|
420
|
+
path?: string;
|
|
421
|
+
}
|
|
422
|
+
interface EntryRoute extends Route {
|
|
423
|
+
hasAction: boolean;
|
|
424
|
+
hasLoader: boolean;
|
|
425
|
+
hasClientAction: boolean;
|
|
426
|
+
hasClientLoader: boolean;
|
|
427
|
+
hasErrorBoundary: boolean;
|
|
428
|
+
imports?: string[];
|
|
429
|
+
css?: string[];
|
|
430
|
+
module: string;
|
|
431
|
+
parentId?: string;
|
|
432
|
+
}
|
|
433
|
+
declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, future: FutureConfig, isSpaMode: boolean): DataRouteObject[];
|
|
434
|
+
declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
|
|
435
|
+
declare function shouldHydrateRouteLoader(route: EntryRoute, routeModule: RouteModule, isSpaMode: boolean): boolean;
|
|
436
|
+
|
|
437
|
+
type ParamKeyValuePair = [string, string];
|
|
438
|
+
type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
|
|
439
|
+
/**
|
|
440
|
+
Creates a URLSearchParams object using the given initializer.
|
|
441
|
+
|
|
442
|
+
This is identical to `new URLSearchParams(init)` except it also
|
|
443
|
+
supports arrays as values in the object form of the initializer
|
|
444
|
+
instead of just strings. This is convenient when you need multiple
|
|
445
|
+
values for a given key, but don't want to use an array initializer.
|
|
446
|
+
|
|
447
|
+
For example, instead of:
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
let searchParams = new URLSearchParams([
|
|
451
|
+
['sort', 'name'],
|
|
452
|
+
['sort', 'price']
|
|
453
|
+
]);
|
|
454
|
+
```
|
|
455
|
+
you can do:
|
|
456
|
+
|
|
457
|
+
```
|
|
458
|
+
let searchParams = createSearchParams({
|
|
459
|
+
sort: ['name', 'price']
|
|
460
|
+
});
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
@category Utils
|
|
464
|
+
*/
|
|
465
|
+
declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
|
|
466
|
+
type JsonObject = {
|
|
467
|
+
[Key in string]: JsonValue;
|
|
468
|
+
} & {
|
|
469
|
+
[Key in string]?: JsonValue | undefined;
|
|
470
|
+
};
|
|
471
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
472
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
473
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
474
|
+
type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
|
|
475
|
+
/**
|
|
476
|
+
* Submit options shared by both navigations and fetchers
|
|
477
|
+
*/
|
|
478
|
+
interface SharedSubmitOptions {
|
|
479
|
+
/**
|
|
480
|
+
* The HTTP method used to submit the form. Overrides `<form method>`.
|
|
481
|
+
* Defaults to "GET".
|
|
482
|
+
*/
|
|
483
|
+
method?: HTMLFormMethod;
|
|
484
|
+
/**
|
|
485
|
+
* The action URL path used to submit the form. Overrides `<form action>`.
|
|
486
|
+
* Defaults to the path of the current route.
|
|
487
|
+
*/
|
|
488
|
+
action?: string;
|
|
489
|
+
/**
|
|
490
|
+
* The encoding used to submit the form. Overrides `<form encType>`.
|
|
491
|
+
* Defaults to "application/x-www-form-urlencoded".
|
|
492
|
+
*/
|
|
493
|
+
encType?: FormEncType;
|
|
494
|
+
/**
|
|
495
|
+
* Determines whether the form action is relative to the route hierarchy or
|
|
496
|
+
* the pathname. Use this if you want to opt out of navigating the route
|
|
497
|
+
* hierarchy and want to instead route based on /-delimited URL segments
|
|
498
|
+
*/
|
|
499
|
+
relative?: RelativeRoutingType;
|
|
500
|
+
/**
|
|
501
|
+
* In browser-based environments, prevent resetting scroll after this
|
|
502
|
+
* navigation when using the <ScrollRestoration> component
|
|
503
|
+
*/
|
|
504
|
+
preventScrollReset?: boolean;
|
|
505
|
+
/**
|
|
506
|
+
* Enable flushSync for this submission's state updates
|
|
507
|
+
*/
|
|
508
|
+
flushSync?: boolean;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Submit options available to fetchers
|
|
512
|
+
*/
|
|
513
|
+
interface FetcherSubmitOptions extends SharedSubmitOptions {
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Submit options available to navigations
|
|
517
|
+
*/
|
|
518
|
+
interface SubmitOptions extends FetcherSubmitOptions {
|
|
519
|
+
/**
|
|
520
|
+
* Set `true` to replace the current entry in the browser's history stack
|
|
521
|
+
* instead of creating a new one (i.e. stay on "the same page"). Defaults
|
|
522
|
+
* to `false`.
|
|
523
|
+
*/
|
|
524
|
+
replace?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* State object to add to the history stack entry for this navigation
|
|
527
|
+
*/
|
|
528
|
+
state?: any;
|
|
529
|
+
/**
|
|
530
|
+
* Indicate a specific fetcherKey to use when using navigate=false
|
|
531
|
+
*/
|
|
532
|
+
fetcherKey?: string;
|
|
533
|
+
/**
|
|
534
|
+
* navigate=false will use a fetcher instead of a navigation
|
|
535
|
+
*/
|
|
536
|
+
navigate?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* Enable view transitions on this submission navigation
|
|
539
|
+
*/
|
|
540
|
+
viewTransition?: boolean;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
|
|
544
|
+
/**
|
|
545
|
+
* Defines the discovery behavior of the link:
|
|
546
|
+
*
|
|
547
|
+
* - "render" - default, discover the route when the link renders
|
|
548
|
+
* - "none" - don't eagerly discover, only discover if the link is clicked
|
|
549
|
+
*/
|
|
550
|
+
type DiscoverBehavior = "render" | "none";
|
|
551
|
+
/**
|
|
552
|
+
* Defines the prefetching behavior of the link:
|
|
553
|
+
*
|
|
554
|
+
* - "none": Never fetched
|
|
555
|
+
* - "intent": Fetched when the user focuses or hovers the link
|
|
556
|
+
* - "render": Fetched when the link is rendered
|
|
557
|
+
* - "viewport": Fetched when the link is in the viewport
|
|
558
|
+
*/
|
|
559
|
+
type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
|
|
560
|
+
/**
|
|
561
|
+
Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
|
|
562
|
+
|
|
563
|
+
```tsx
|
|
564
|
+
import { Links } from "react-router";
|
|
565
|
+
|
|
566
|
+
export default function Root() {
|
|
567
|
+
return (
|
|
568
|
+
<html>
|
|
569
|
+
<head>
|
|
570
|
+
<Links />
|
|
571
|
+
</head>
|
|
572
|
+
<body></body>
|
|
573
|
+
</html>
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
@category Components
|
|
579
|
+
*/
|
|
580
|
+
declare function Links(): React.JSX.Element;
|
|
581
|
+
/**
|
|
582
|
+
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.
|
|
583
|
+
|
|
584
|
+
```tsx
|
|
585
|
+
import { PrefetchPageLinks } from "react-router"
|
|
586
|
+
|
|
587
|
+
<PrefetchPageLinks page="/absolute/path" />
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
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.
|
|
591
|
+
|
|
592
|
+
@category Components
|
|
593
|
+
*/
|
|
594
|
+
declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
|
|
595
|
+
/**
|
|
596
|
+
Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
|
|
597
|
+
|
|
598
|
+
```tsx
|
|
599
|
+
import { Meta } from "react-router";
|
|
600
|
+
|
|
601
|
+
export default function Root() {
|
|
602
|
+
return (
|
|
603
|
+
<html>
|
|
604
|
+
<head>
|
|
605
|
+
<Meta />
|
|
606
|
+
</head>
|
|
607
|
+
</html>
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
@category Components
|
|
613
|
+
*/
|
|
614
|
+
declare function Meta(): React.JSX.Element;
|
|
615
|
+
/**
|
|
616
|
+
A couple common attributes:
|
|
617
|
+
|
|
618
|
+
- `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
|
|
619
|
+
- `<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.
|
|
620
|
+
|
|
621
|
+
You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
|
|
622
|
+
|
|
623
|
+
@category Types
|
|
624
|
+
*/
|
|
625
|
+
type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
|
|
626
|
+
/**
|
|
627
|
+
Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
|
|
628
|
+
|
|
629
|
+
```tsx
|
|
630
|
+
import { Scripts } from "react-router";
|
|
631
|
+
|
|
632
|
+
export default function Root() {
|
|
633
|
+
return (
|
|
634
|
+
<html>
|
|
635
|
+
<head />
|
|
636
|
+
<body>
|
|
637
|
+
<Scripts />
|
|
638
|
+
</body>
|
|
639
|
+
</html>
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
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.
|
|
645
|
+
|
|
646
|
+
@category Components
|
|
647
|
+
*/
|
|
648
|
+
declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
|
|
649
|
+
|
|
650
|
+
declare global {
|
|
651
|
+
const REACT_ROUTER_VERSION: string;
|
|
652
|
+
}
|
|
10
653
|
interface DOMRouterOpts {
|
|
11
654
|
basename?: string;
|
|
12
|
-
future?: Partial<FutureConfig>;
|
|
655
|
+
future?: Partial<FutureConfig$1>;
|
|
13
656
|
hydrationData?: HydrationState;
|
|
14
657
|
dataStrategy?: DataStrategyFunction;
|
|
15
658
|
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
|
@@ -18,15 +661,15 @@ interface DOMRouterOpts {
|
|
|
18
661
|
/**
|
|
19
662
|
* @category Routers
|
|
20
663
|
*/
|
|
21
|
-
|
|
664
|
+
declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
|
|
22
665
|
/**
|
|
23
666
|
* @category Routers
|
|
24
667
|
*/
|
|
25
|
-
|
|
668
|
+
declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
|
|
26
669
|
/**
|
|
27
670
|
* @category Types
|
|
28
671
|
*/
|
|
29
|
-
|
|
672
|
+
interface BrowserRouterProps {
|
|
30
673
|
basename?: string;
|
|
31
674
|
children?: React.ReactNode;
|
|
32
675
|
window?: Window;
|
|
@@ -36,11 +679,11 @@ export interface BrowserRouterProps {
|
|
|
36
679
|
*
|
|
37
680
|
* @category Router Components
|
|
38
681
|
*/
|
|
39
|
-
|
|
682
|
+
declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
|
|
40
683
|
/**
|
|
41
684
|
* @category Types
|
|
42
685
|
*/
|
|
43
|
-
|
|
686
|
+
interface HashRouterProps {
|
|
44
687
|
basename?: string;
|
|
45
688
|
children?: React.ReactNode;
|
|
46
689
|
window?: Window;
|
|
@@ -51,11 +694,11 @@ export interface HashRouterProps {
|
|
|
51
694
|
*
|
|
52
695
|
* @category Router Components
|
|
53
696
|
*/
|
|
54
|
-
|
|
697
|
+
declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
|
|
55
698
|
/**
|
|
56
699
|
* @category Types
|
|
57
700
|
*/
|
|
58
|
-
|
|
701
|
+
interface HistoryRouterProps {
|
|
59
702
|
basename?: string;
|
|
60
703
|
children?: React.ReactNode;
|
|
61
704
|
history: History;
|
|
@@ -69,14 +712,14 @@ export interface HistoryRouterProps {
|
|
|
69
712
|
* @name unstable_HistoryRouter
|
|
70
713
|
* @category Router Components
|
|
71
714
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
715
|
+
declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
|
|
716
|
+
declare namespace HistoryRouter {
|
|
74
717
|
var displayName: string;
|
|
75
718
|
}
|
|
76
719
|
/**
|
|
77
720
|
* @category Types
|
|
78
721
|
*/
|
|
79
|
-
|
|
722
|
+
interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
|
80
723
|
/**
|
|
81
724
|
Defines the link discovery behavior
|
|
82
725
|
|
|
@@ -234,7 +877,7 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
|
|
|
234
877
|
|
|
235
878
|
@category Components
|
|
236
879
|
*/
|
|
237
|
-
|
|
880
|
+
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
238
881
|
/**
|
|
239
882
|
The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
|
|
240
883
|
|
|
@@ -269,7 +912,7 @@ export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.Ref
|
|
|
269
912
|
```
|
|
270
913
|
|
|
271
914
|
*/
|
|
272
|
-
|
|
915
|
+
type NavLinkRenderProps = {
|
|
273
916
|
/**
|
|
274
917
|
* Indicates if the link's URL matches the current location.
|
|
275
918
|
*/
|
|
@@ -286,7 +929,7 @@ export type NavLinkRenderProps = {
|
|
|
286
929
|
/**
|
|
287
930
|
* @category Types
|
|
288
931
|
*/
|
|
289
|
-
|
|
932
|
+
interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
|
|
290
933
|
/**
|
|
291
934
|
Can be regular React children or a function that receives an object with the active and pending states of the link.
|
|
292
935
|
|
|
@@ -361,7 +1004,7 @@ export interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "c
|
|
|
361
1004
|
|
|
362
1005
|
@category Components
|
|
363
1006
|
*/
|
|
364
|
-
|
|
1007
|
+
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
365
1008
|
/**
|
|
366
1009
|
* Form props shared by navigations and fetchers
|
|
367
1010
|
*/
|
|
@@ -403,13 +1046,13 @@ interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
|
403
1046
|
* Form props available to fetchers
|
|
404
1047
|
* @category Types
|
|
405
1048
|
*/
|
|
406
|
-
|
|
1049
|
+
interface FetcherFormProps extends SharedFormProps {
|
|
407
1050
|
}
|
|
408
1051
|
/**
|
|
409
1052
|
* Form props available to navigations
|
|
410
1053
|
* @category Types
|
|
411
1054
|
*/
|
|
412
|
-
|
|
1055
|
+
interface FormProps extends SharedFormProps {
|
|
413
1056
|
discover?: DiscoverBehavior;
|
|
414
1057
|
/**
|
|
415
1058
|
* Indicates a specific fetcherKey to use when using `navigate={false}` so you
|
|
@@ -470,8 +1113,8 @@ function NewEvent() {
|
|
|
470
1113
|
|
|
471
1114
|
@category Components
|
|
472
1115
|
*/
|
|
473
|
-
|
|
474
|
-
|
|
1116
|
+
declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
|
|
1117
|
+
type ScrollRestorationProps = ScriptsProps & {
|
|
475
1118
|
/**
|
|
476
1119
|
Defines the key used to restore scroll positions.
|
|
477
1120
|
|
|
@@ -513,8 +1156,8 @@ export type ScrollRestorationProps = ScriptsProps & {
|
|
|
513
1156
|
|
|
514
1157
|
@category Components
|
|
515
1158
|
*/
|
|
516
|
-
|
|
517
|
-
|
|
1159
|
+
declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
|
|
1160
|
+
declare namespace ScrollRestoration {
|
|
518
1161
|
var displayName: string;
|
|
519
1162
|
}
|
|
520
1163
|
/**
|
|
@@ -524,7 +1167,7 @@ export declare namespace ScrollRestoration {
|
|
|
524
1167
|
*
|
|
525
1168
|
* @category Hooks
|
|
526
1169
|
*/
|
|
527
|
-
|
|
1170
|
+
declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
|
|
528
1171
|
target?: React.HTMLAttributeAnchorTarget;
|
|
529
1172
|
replace?: boolean;
|
|
530
1173
|
state?: any;
|
|
@@ -546,7 +1189,7 @@ export declare function useLinkClickHandler<E extends Element = HTMLAnchorElemen
|
|
|
546
1189
|
|
|
547
1190
|
@category Hooks
|
|
548
1191
|
*/
|
|
549
|
-
|
|
1192
|
+
declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
|
|
550
1193
|
/**
|
|
551
1194
|
Sets new search params and causes a navigation when called.
|
|
552
1195
|
|
|
@@ -575,11 +1218,11 @@ export declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URL
|
|
|
575
1218
|
/>
|
|
576
1219
|
```
|
|
577
1220
|
*/
|
|
578
|
-
|
|
1221
|
+
type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
|
|
579
1222
|
/**
|
|
580
1223
|
* Submits a HTML `<form>` to the server without reloading the page.
|
|
581
1224
|
*/
|
|
582
|
-
|
|
1225
|
+
interface SubmitFunction {
|
|
583
1226
|
(
|
|
584
1227
|
/**
|
|
585
1228
|
Can be multiple types of elements and objects
|
|
@@ -627,7 +1270,7 @@ export interface SubmitFunction {
|
|
|
627
1270
|
/**
|
|
628
1271
|
* Submits a fetcher `<form>` to the server without reloading the page.
|
|
629
1272
|
*/
|
|
630
|
-
|
|
1273
|
+
interface FetcherSubmitFunction {
|
|
631
1274
|
(
|
|
632
1275
|
/**
|
|
633
1276
|
Can be multiple types of elements and objects
|
|
@@ -688,7 +1331,7 @@ export interface FetcherSubmitFunction {
|
|
|
688
1331
|
|
|
689
1332
|
@category Hooks
|
|
690
1333
|
*/
|
|
691
|
-
|
|
1334
|
+
declare function useSubmit(): SubmitFunction;
|
|
692
1335
|
/**
|
|
693
1336
|
Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.
|
|
694
1337
|
|
|
@@ -708,7 +1351,7 @@ export declare function useSubmit(): SubmitFunction;
|
|
|
708
1351
|
|
|
709
1352
|
@category Hooks
|
|
710
1353
|
*/
|
|
711
|
-
|
|
1354
|
+
declare function useFormAction(
|
|
712
1355
|
/**
|
|
713
1356
|
* The action to append to the closest route URL.
|
|
714
1357
|
*/
|
|
@@ -722,7 +1365,7 @@ The return value of `useFetcher` that keeps track of the state of a fetcher.
|
|
|
722
1365
|
let fetcher = useFetcher();
|
|
723
1366
|
```
|
|
724
1367
|
*/
|
|
725
|
-
|
|
1368
|
+
type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
726
1369
|
/**
|
|
727
1370
|
Just like {@link Form} except it doesn't cause a navigation.
|
|
728
1371
|
|
|
@@ -835,7 +1478,7 @@ export type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
|
835
1478
|
|
|
836
1479
|
@category Hooks
|
|
837
1480
|
*/
|
|
838
|
-
|
|
1481
|
+
declare function useFetcher<T = any>({ key, }?: {
|
|
839
1482
|
/**
|
|
840
1483
|
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:
|
|
841
1484
|
|
|
@@ -871,13 +1514,13 @@ export declare function useFetcher<T = any>({ key, }?: {
|
|
|
871
1514
|
|
|
872
1515
|
@category Hooks
|
|
873
1516
|
*/
|
|
874
|
-
|
|
1517
|
+
declare function useFetchers(): (Fetcher & {
|
|
875
1518
|
key: string;
|
|
876
1519
|
})[];
|
|
877
1520
|
/**
|
|
878
1521
|
* When rendered inside a RouterProvider, will restore scroll positions on navigations
|
|
879
1522
|
*/
|
|
880
|
-
|
|
1523
|
+
declare function useScrollRestoration({ getKey, storageKey, }?: {
|
|
881
1524
|
getKey?: GetScrollRestorationKeyFunction;
|
|
882
1525
|
storageKey?: string;
|
|
883
1526
|
}): void;
|
|
@@ -886,7 +1529,7 @@ export declare function useScrollRestoration({ getKey, storageKey, }?: {
|
|
|
886
1529
|
*
|
|
887
1530
|
* @category Hooks
|
|
888
1531
|
*/
|
|
889
|
-
|
|
1532
|
+
declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
|
|
890
1533
|
capture?: boolean;
|
|
891
1534
|
}): void;
|
|
892
1535
|
/**
|
|
@@ -925,7 +1568,7 @@ export declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) =>
|
|
|
925
1568
|
@category Hooks
|
|
926
1569
|
@name unstable_usePrompt
|
|
927
1570
|
*/
|
|
928
|
-
|
|
1571
|
+
declare function usePrompt({ when, message, }: {
|
|
929
1572
|
when: boolean | BlockerFunction;
|
|
930
1573
|
message: string;
|
|
931
1574
|
}): void;
|
|
@@ -935,7 +1578,18 @@ export declare function usePrompt({ when, message, }: {
|
|
|
935
1578
|
@category Hooks
|
|
936
1579
|
@name useViewTransitionState
|
|
937
1580
|
*/
|
|
938
|
-
|
|
1581
|
+
declare function useViewTransitionState(to: To, opts?: {
|
|
939
1582
|
relative?: RelativeRoutingType;
|
|
940
1583
|
}): boolean;
|
|
941
|
-
|
|
1584
|
+
|
|
1585
|
+
declare global {
|
|
1586
|
+
interface Navigator {
|
|
1587
|
+
connection?: {
|
|
1588
|
+
saveData: boolean;
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
|
|
1593
|
+
declare function useFogOFWarDiscovery(router: Router$1, manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean): void;
|
|
1594
|
+
|
|
1595
|
+
export { useFetchers as $, type AssetsManifest as A, type BrowserRouterProps as B, createBrowserRouter as C, createHashRouter as D, type EntryContext as E, type FutureConfig as F, BrowserRouter as G, type HashRouterProps as H, type IndexRouteProps as I, HashRouter as J, Link as K, type LayoutRouteProps as L, type MemoryRouterProps as M, type NavigateProps as N, type OutletProps as O, type PathRouteProps as P, HistoryRouter as Q, type RouterProviderProps as R, type ScrollRestorationProps as S, NavLink as T, Form as U, ScrollRestoration as V, useLinkClickHandler as W, useSearchParams as X, useSubmit as Y, useFormAction as Z, useFetcher as _, type Route as a, useBeforeUnload as a0, usePrompt as a1, useViewTransitionState as a2, type FetcherSubmitOptions as a3, type ParamKeyValuePair as a4, type SubmitOptions as a5, type URLSearchParamsInit as a6, type SubmitTarget as a7, createSearchParams as a8, Meta as a9, Links as aa, Scripts as ab, PrefetchPageLinks as ac, type ScriptsProps as ad, mapRouteProperties as ae, FrameworkContext as af, getPatchRoutesOnNavigationFunction as ag, useFogOFWarDiscovery as ah, createClientRoutes as ai, createClientRoutesWithHMRRevalidationOptOut as aj, shouldHydrateRouteLoader as ak, useScrollRestoration as al, type AwaitProps as b, type RouteProps as c, type RouterProps as d, type RoutesProps as e, Await as f, MemoryRouter as g, Navigate as h, Outlet as i, Route$1 as j, Router as k, RouterProvider as l, Routes as m, createMemoryRouter as n, createRoutesFromChildren as o, type HistoryRouterProps as p, type LinkProps as q, renderMatches as r, type NavLinkProps as s, type NavLinkRenderProps as t, type FetcherFormProps as u, type FormProps as v, type SetURLSearchParams as w, type SubmitFunction as x, type FetcherSubmitFunction as y, type FetcherWithComponents as z };
|