react-router 7.0.0-pre.1 → 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 +40 -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 -118
- package/dist/{lib/dom/lib.d.ts → fog-of-war-BijhfqFM.d.ts} +700 -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 -74
- package/dist/index.js +9763 -0
- package/dist/index.mjs +225 -11533
- package/dist/lib/types.d.mts +2 -0
- package/dist/lib/types.d.ts +2 -76
- 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 +54 -14
- 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 -123
- package/dist/lib/dom/ssr/data.d.ts +0 -7
- package/dist/lib/dom/ssr/entry.d.ts +0 -47
- 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 -141
- package/dist/lib/dom/ssr/routes-test-stub.d.ts +0 -59
- package/dist/lib/dom/ssr/routes.d.ts +0 -32
- 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 -410
- 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 -540
- package/dist/lib/router/utils.d.ts +0 -505
- 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 -15
- 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/jsonify.d.ts +0 -33
- 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/responses.d.ts +0 -37
- package/dist/lib/server-runtime/routeMatching.d.ts +0 -8
- package/dist/lib/server-runtime/routeModules.d.ts +0 -212
- package/dist/lib/server-runtime/routes.d.ts +0 -31
- 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 -12503
- 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 -12818
- 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,14 +1,658 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
}
|
|
9
653
|
interface DOMRouterOpts {
|
|
10
654
|
basename?: string;
|
|
11
|
-
future?: Partial<FutureConfig>;
|
|
655
|
+
future?: Partial<FutureConfig$1>;
|
|
12
656
|
hydrationData?: HydrationState;
|
|
13
657
|
dataStrategy?: DataStrategyFunction;
|
|
14
658
|
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
|
@@ -17,15 +661,15 @@ interface DOMRouterOpts {
|
|
|
17
661
|
/**
|
|
18
662
|
* @category Routers
|
|
19
663
|
*/
|
|
20
|
-
|
|
664
|
+
declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
|
|
21
665
|
/**
|
|
22
666
|
* @category Routers
|
|
23
667
|
*/
|
|
24
|
-
|
|
668
|
+
declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
|
|
25
669
|
/**
|
|
26
670
|
* @category Types
|
|
27
671
|
*/
|
|
28
|
-
|
|
672
|
+
interface BrowserRouterProps {
|
|
29
673
|
basename?: string;
|
|
30
674
|
children?: React.ReactNode;
|
|
31
675
|
window?: Window;
|
|
@@ -35,11 +679,11 @@ export interface BrowserRouterProps {
|
|
|
35
679
|
*
|
|
36
680
|
* @category Router Components
|
|
37
681
|
*/
|
|
38
|
-
|
|
682
|
+
declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
|
|
39
683
|
/**
|
|
40
684
|
* @category Types
|
|
41
685
|
*/
|
|
42
|
-
|
|
686
|
+
interface HashRouterProps {
|
|
43
687
|
basename?: string;
|
|
44
688
|
children?: React.ReactNode;
|
|
45
689
|
window?: Window;
|
|
@@ -50,11 +694,11 @@ export interface HashRouterProps {
|
|
|
50
694
|
*
|
|
51
695
|
* @category Router Components
|
|
52
696
|
*/
|
|
53
|
-
|
|
697
|
+
declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
|
|
54
698
|
/**
|
|
55
699
|
* @category Types
|
|
56
700
|
*/
|
|
57
|
-
|
|
701
|
+
interface HistoryRouterProps {
|
|
58
702
|
basename?: string;
|
|
59
703
|
children?: React.ReactNode;
|
|
60
704
|
history: History;
|
|
@@ -68,14 +712,14 @@ export interface HistoryRouterProps {
|
|
|
68
712
|
* @name unstable_HistoryRouter
|
|
69
713
|
* @category Router Components
|
|
70
714
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
715
|
+
declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
|
|
716
|
+
declare namespace HistoryRouter {
|
|
73
717
|
var displayName: string;
|
|
74
718
|
}
|
|
75
719
|
/**
|
|
76
720
|
* @category Types
|
|
77
721
|
*/
|
|
78
|
-
|
|
722
|
+
interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
|
79
723
|
/**
|
|
80
724
|
Defines the link discovery behavior
|
|
81
725
|
|
|
@@ -233,7 +877,7 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
|
|
|
233
877
|
|
|
234
878
|
@category Components
|
|
235
879
|
*/
|
|
236
|
-
|
|
880
|
+
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
237
881
|
/**
|
|
238
882
|
The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
|
|
239
883
|
|
|
@@ -268,7 +912,7 @@ export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.Ref
|
|
|
268
912
|
```
|
|
269
913
|
|
|
270
914
|
*/
|
|
271
|
-
|
|
915
|
+
type NavLinkRenderProps = {
|
|
272
916
|
/**
|
|
273
917
|
* Indicates if the link's URL matches the current location.
|
|
274
918
|
*/
|
|
@@ -285,7 +929,7 @@ export type NavLinkRenderProps = {
|
|
|
285
929
|
/**
|
|
286
930
|
* @category Types
|
|
287
931
|
*/
|
|
288
|
-
|
|
932
|
+
interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
|
|
289
933
|
/**
|
|
290
934
|
Can be regular React children or a function that receives an object with the active and pending states of the link.
|
|
291
935
|
|
|
@@ -360,7 +1004,7 @@ export interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "c
|
|
|
360
1004
|
|
|
361
1005
|
@category Components
|
|
362
1006
|
*/
|
|
363
|
-
|
|
1007
|
+
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
364
1008
|
/**
|
|
365
1009
|
* Form props shared by navigations and fetchers
|
|
366
1010
|
*/
|
|
@@ -402,13 +1046,13 @@ interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
|
402
1046
|
* Form props available to fetchers
|
|
403
1047
|
* @category Types
|
|
404
1048
|
*/
|
|
405
|
-
|
|
1049
|
+
interface FetcherFormProps extends SharedFormProps {
|
|
406
1050
|
}
|
|
407
1051
|
/**
|
|
408
1052
|
* Form props available to navigations
|
|
409
1053
|
* @category Types
|
|
410
1054
|
*/
|
|
411
|
-
|
|
1055
|
+
interface FormProps extends SharedFormProps {
|
|
412
1056
|
discover?: DiscoverBehavior;
|
|
413
1057
|
/**
|
|
414
1058
|
* Indicates a specific fetcherKey to use when using `navigate={false}` so you
|
|
@@ -469,8 +1113,8 @@ function NewEvent() {
|
|
|
469
1113
|
|
|
470
1114
|
@category Components
|
|
471
1115
|
*/
|
|
472
|
-
|
|
473
|
-
|
|
1116
|
+
declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
|
|
1117
|
+
type ScrollRestorationProps = ScriptsProps & {
|
|
474
1118
|
/**
|
|
475
1119
|
Defines the key used to restore scroll positions.
|
|
476
1120
|
|
|
@@ -512,8 +1156,8 @@ export type ScrollRestorationProps = ScriptsProps & {
|
|
|
512
1156
|
|
|
513
1157
|
@category Components
|
|
514
1158
|
*/
|
|
515
|
-
|
|
516
|
-
|
|
1159
|
+
declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
|
|
1160
|
+
declare namespace ScrollRestoration {
|
|
517
1161
|
var displayName: string;
|
|
518
1162
|
}
|
|
519
1163
|
/**
|
|
@@ -523,7 +1167,7 @@ export declare namespace ScrollRestoration {
|
|
|
523
1167
|
*
|
|
524
1168
|
* @category Hooks
|
|
525
1169
|
*/
|
|
526
|
-
|
|
1170
|
+
declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
|
|
527
1171
|
target?: React.HTMLAttributeAnchorTarget;
|
|
528
1172
|
replace?: boolean;
|
|
529
1173
|
state?: any;
|
|
@@ -545,7 +1189,7 @@ export declare function useLinkClickHandler<E extends Element = HTMLAnchorElemen
|
|
|
545
1189
|
|
|
546
1190
|
@category Hooks
|
|
547
1191
|
*/
|
|
548
|
-
|
|
1192
|
+
declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
|
|
549
1193
|
/**
|
|
550
1194
|
Sets new search params and causes a navigation when called.
|
|
551
1195
|
|
|
@@ -574,11 +1218,11 @@ export declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URL
|
|
|
574
1218
|
/>
|
|
575
1219
|
```
|
|
576
1220
|
*/
|
|
577
|
-
|
|
1221
|
+
type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
|
|
578
1222
|
/**
|
|
579
1223
|
* Submits a HTML `<form>` to the server without reloading the page.
|
|
580
1224
|
*/
|
|
581
|
-
|
|
1225
|
+
interface SubmitFunction {
|
|
582
1226
|
(
|
|
583
1227
|
/**
|
|
584
1228
|
Can be multiple types of elements and objects
|
|
@@ -626,7 +1270,7 @@ export interface SubmitFunction {
|
|
|
626
1270
|
/**
|
|
627
1271
|
* Submits a fetcher `<form>` to the server without reloading the page.
|
|
628
1272
|
*/
|
|
629
|
-
|
|
1273
|
+
interface FetcherSubmitFunction {
|
|
630
1274
|
(
|
|
631
1275
|
/**
|
|
632
1276
|
Can be multiple types of elements and objects
|
|
@@ -687,7 +1331,7 @@ export interface FetcherSubmitFunction {
|
|
|
687
1331
|
|
|
688
1332
|
@category Hooks
|
|
689
1333
|
*/
|
|
690
|
-
|
|
1334
|
+
declare function useSubmit(): SubmitFunction;
|
|
691
1335
|
/**
|
|
692
1336
|
Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.
|
|
693
1337
|
|
|
@@ -707,7 +1351,7 @@ export declare function useSubmit(): SubmitFunction;
|
|
|
707
1351
|
|
|
708
1352
|
@category Hooks
|
|
709
1353
|
*/
|
|
710
|
-
|
|
1354
|
+
declare function useFormAction(
|
|
711
1355
|
/**
|
|
712
1356
|
* The action to append to the closest route URL.
|
|
713
1357
|
*/
|
|
@@ -721,7 +1365,7 @@ The return value of `useFetcher` that keeps track of the state of a fetcher.
|
|
|
721
1365
|
let fetcher = useFetcher();
|
|
722
1366
|
```
|
|
723
1367
|
*/
|
|
724
|
-
|
|
1368
|
+
type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
725
1369
|
/**
|
|
726
1370
|
Just like {@link Form} except it doesn't cause a navigation.
|
|
727
1371
|
|
|
@@ -834,7 +1478,7 @@ export type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
|
834
1478
|
|
|
835
1479
|
@category Hooks
|
|
836
1480
|
*/
|
|
837
|
-
|
|
1481
|
+
declare function useFetcher<T = any>({ key, }?: {
|
|
838
1482
|
/**
|
|
839
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:
|
|
840
1484
|
|
|
@@ -853,7 +1497,7 @@ export declare function useFetcher<TData = any>({ key, }?: {
|
|
|
853
1497
|
```
|
|
854
1498
|
*/
|
|
855
1499
|
key?: string;
|
|
856
|
-
}): FetcherWithComponents<
|
|
1500
|
+
}): FetcherWithComponents<SerializeFrom<T>>;
|
|
857
1501
|
/**
|
|
858
1502
|
Returns an array of all in-flight fetchers. This is useful for components throughout the app that didn't create the fetchers but want to use their submissions to participate in optimistic UI.
|
|
859
1503
|
|
|
@@ -870,13 +1514,13 @@ export declare function useFetcher<TData = any>({ key, }?: {
|
|
|
870
1514
|
|
|
871
1515
|
@category Hooks
|
|
872
1516
|
*/
|
|
873
|
-
|
|
1517
|
+
declare function useFetchers(): (Fetcher & {
|
|
874
1518
|
key: string;
|
|
875
1519
|
})[];
|
|
876
1520
|
/**
|
|
877
1521
|
* When rendered inside a RouterProvider, will restore scroll positions on navigations
|
|
878
1522
|
*/
|
|
879
|
-
|
|
1523
|
+
declare function useScrollRestoration({ getKey, storageKey, }?: {
|
|
880
1524
|
getKey?: GetScrollRestorationKeyFunction;
|
|
881
1525
|
storageKey?: string;
|
|
882
1526
|
}): void;
|
|
@@ -885,7 +1529,7 @@ export declare function useScrollRestoration({ getKey, storageKey, }?: {
|
|
|
885
1529
|
*
|
|
886
1530
|
* @category Hooks
|
|
887
1531
|
*/
|
|
888
|
-
|
|
1532
|
+
declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
|
|
889
1533
|
capture?: boolean;
|
|
890
1534
|
}): void;
|
|
891
1535
|
/**
|
|
@@ -924,7 +1568,7 @@ export declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) =>
|
|
|
924
1568
|
@category Hooks
|
|
925
1569
|
@name unstable_usePrompt
|
|
926
1570
|
*/
|
|
927
|
-
|
|
1571
|
+
declare function usePrompt({ when, message, }: {
|
|
928
1572
|
when: boolean | BlockerFunction;
|
|
929
1573
|
message: string;
|
|
930
1574
|
}): void;
|
|
@@ -934,7 +1578,18 @@ export declare function usePrompt({ when, message, }: {
|
|
|
934
1578
|
@category Hooks
|
|
935
1579
|
@name useViewTransitionState
|
|
936
1580
|
*/
|
|
937
|
-
|
|
1581
|
+
declare function useViewTransitionState(to: To, opts?: {
|
|
938
1582
|
relative?: RelativeRoutingType;
|
|
939
1583
|
}): boolean;
|
|
940
|
-
|
|
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 };
|