react-router 7.6.1-pre.2 → 7.6.2
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 +12 -18
- package/dist/development/{chunk-H4Y5ODCL.mjs → chunk-NL6KNZEE.mjs} +48 -39
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.js +1 -1
- package/dist/development/dom-export.mjs +2 -2
- package/dist/development/index.d.mts +8 -389
- package/dist/development/index.d.ts +819 -799
- package/dist/development/index.js +51 -39
- package/dist/development/index.mjs +9 -3
- package/dist/development/lib/types/internal.d.mts +1 -1
- package/dist/development/lib/types/internal.d.ts +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/{production/lib-B8x_tOvL.d.mts → development/lib-C1JSsICm.d.mts} +537 -136
- package/dist/{production/register-BkDIKxVz.d.ts → development/register-DCE0tH5m.d.ts} +1 -1
- package/dist/{production/route-data-WyrduLgj.d.mts → development/route-data-ByAYLHuM.d.mts} +1 -1
- package/dist/production/{chunk-WUZRT63N.mjs → chunk-JRQCFVZH.mjs} +48 -39
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.js +1 -1
- package/dist/production/dom-export.mjs +2 -2
- package/dist/production/index.d.mts +8 -389
- package/dist/production/index.d.ts +819 -799
- package/dist/production/index.js +51 -39
- package/dist/production/index.mjs +9 -3
- package/dist/production/lib/types/internal.d.mts +1 -1
- package/dist/production/lib/types/internal.d.ts +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/lib-B8x_tOvL.d.mts → production/lib-C1JSsICm.d.mts} +537 -136
- package/dist/{development/register-BkDIKxVz.d.ts → production/register-DCE0tH5m.d.ts} +1 -1
- package/dist/{development/route-data-WyrduLgj.d.mts → production/route-data-ByAYLHuM.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as Router, b as RouteModules, D as DataStrategyFunction,
|
|
2
|
-
export {
|
|
3
|
-
import { A as AssetsManifest, E as EntryContext, F as FutureConfig$1, S as ServerBuild } from './lib-
|
|
4
|
-
export {
|
|
1
|
+
import { a as Router, b as RouteModules, D as DataStrategyFunction, L as Location, S as StaticHandlerContext, c as RouteObject, d as StaticHandler, F as FutureConfig, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, u as unstable_InitialContext, e as IndexRouteObject, N as NonIndexRouteObject, f as LoaderFunction, A as ActionFunction, M as MetaFunction, g as LinksFunction, h as MiddlewareEnabled, i as AppLoadContext, E as Equal, j as RouterState, P as PatchRoutesOnNavigationFunction, k as DataRouteObject, l as ClientLoaderFunction, m as Path } from './route-data-ByAYLHuM.mjs';
|
|
2
|
+
export { y as ActionFunctionArgs, B as Blocker, s as BlockerFunction, au as ClientActionFunction, av as ClientActionFunctionArgs, aw as ClientLoaderFunctionArgs, ap as DataRouteMatch, z as DataStrategyFunctionArgs, J as DataStrategyMatch, K as DataStrategyResult, Q as ErrorResponse, o as Fetcher, U as FormEncType, V as FormMethod, aE as Future, G as GetScrollPositionFunction, n as GetScrollRestorationKeyFunction, W as HTMLFormMethod, ax as HeadersArgs, ay as HeadersFunction, aC as HtmlLinkDescriptor, af as IDLE_BLOCKER, ae as IDLE_FETCHER, ad as IDLE_NAVIGATION, X as LazyRouteFunction, aD as LinkDescriptor, Y as LoaderFunctionArgs, az as MetaArgs, aA as MetaDescriptor, aq as NavigateOptions, p as Navigation, q as NavigationStates, aa as NavigationType, ar as Navigator, aB as PageLinkDescriptor, _ as ParamParseKey, $ as Params, as as PatchRoutesOnNavigationFunctionArgs, a0 as PathMatch, a1 as PathParam, a2 as PathPattern, a3 as RedirectFunction, r as RelativeRoutingType, x as RevalidationState, at as RouteMatch, w as RouterFetchOptions, R as RouterInit, v as RouterNavigateOptions, t as RouterSubscriber, a5 as ShouldRevalidateFunction, a6 as ShouldRevalidateFunctionArgs, T as To, a7 as UIMatch, aK as UNSAFE_DataRouterContext, aL as UNSAFE_DataRouterStateContext, O as UNSAFE_DataWithResponseInit, aJ as UNSAFE_ErrorResponseImpl, aM as UNSAFE_FetchersContext, aN as UNSAFE_LocationContext, aO as UNSAFE_NavigationContext, aP as UNSAFE_RouteContext, aQ as UNSAFE_ViewTransitionContext, aG as UNSAFE_createBrowserHistory, aI as UNSAFE_createRouter, aH as UNSAFE_invariant, ab as createPath, ag as data, ah as generatePath, ai as isRouteErrorResponse, aj as matchPath, ak as matchRoutes, ac as parsePath, al as redirect, am as redirectDocument, an as replace, ao as resolvePath, Z as unstable_MiddlewareFunction, a4 as unstable_RouterContext, a9 as unstable_RouterContextProvider, aF as unstable_SerializesTo, a8 as unstable_createContext } from './route-data-ByAYLHuM.mjs';
|
|
3
|
+
import { A as AssetsManifest, E as EntryContext, F as FutureConfig$1, a as RouteComponentType, H as HydrateFallbackType, b as ErrorBoundaryType, S as ServerBuild } from './lib-C1JSsICm.mjs';
|
|
4
|
+
export { h as Await, c as AwaitProps, af as BrowserRouter, $ as BrowserRouterProps, a0 as DOMRouterOpts, a6 as FetcherFormProps, ab as FetcherSubmitFunction, av as FetcherSubmitOptions, ac as FetcherWithComponents, ak as Form, a7 as FormProps, aG as HandleDataRequestFunction, aH as HandleDocumentRequestFunction, aI as HandleErrorFunction, ag as HashRouter, a1 as HashRouterProps, a2 as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, ah as Link, a3 as LinkProps, aC as Links, i as MemoryRouter, M as MemoryRouterOpts, d as MemoryRouterProps, aB as Meta, aj as NavLink, a4 as NavLinkProps, a5 as NavLinkRenderProps, j as Navigate, t as NavigateFunction, N as NavigateProps, k as Outlet, O as OutletProps, aw as ParamKeyValuePair, P as PathRouteProps, aE as PrefetchPageLinks, l as Route, e as RouteProps, m as Router, f as RouterProps, n as RouterProvider, R as RouterProviderProps, o as Routes, g as RoutesProps, aD as Scripts, aF as ScriptsProps, al as ScrollRestoration, a8 as ScrollRestorationProps, aJ as ServerEntryModule, a9 as SetURLSearchParams, aa as SubmitFunction, ax as SubmitOptions, az as SubmitTarget, aP as UNSAFE_FrameworkContext, aQ as UNSAFE_createClientRoutes, aR as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, aK as UNSAFE_hydrationRouteProperties, aL as UNSAFE_mapRouteProperties, aS as UNSAFE_shouldHydrateRouteLoader, aT as UNSAFE_useScrollRestoration, aM as UNSAFE_withComponentProps, aO as UNSAFE_withErrorBoundaryProps, aN as UNSAFE_withHydrateFallbackProps, ay as URLSearchParamsInit, ad as createBrowserRouter, ae as createHashRouter, p as createMemoryRouter, q as createRoutesFromChildren, r as createRoutesFromElements, aA as createSearchParams, s as renderMatches, ai as unstable_HistoryRouter, at as unstable_usePrompt, v as useActionData, w as useAsyncError, x as useAsyncValue, as as useBeforeUnload, u as useBlocker, aq as useFetcher, ar as useFetchers, ap as useFormAction, y as useHref, z as useInRouterContext, am as useLinkClickHandler, B as useLoaderData, C as useLocation, D as useMatch, G as useMatches, J as useNavigate, K as useNavigation, Q as useNavigationType, T as useOutlet, U as useOutletContext, V as useParams, W as useResolvedPath, X as useRevalidator, Y as useRouteError, Z as useRouteLoaderData, _ as useRoutes, an as useSearchParams, ao as useSubmit, au as useViewTransitionState } from './lib-C1JSsICm.mjs';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { ReactElement } from 'react';
|
|
7
7
|
import { ParseOptions, SerializeOptions } from 'cookie';
|
|
@@ -25,373 +25,6 @@ declare enum ServerMode {
|
|
|
25
25
|
Test = "test"
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
Resolves a URL against the current location.
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
import { useHref } from "react-router"
|
|
33
|
-
|
|
34
|
-
function SomeComponent() {
|
|
35
|
-
let href = useHref("some/where");
|
|
36
|
-
// "/resolved/some/where"
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
@category Hooks
|
|
41
|
-
*/
|
|
42
|
-
declare function useHref(to: To, { relative }?: {
|
|
43
|
-
relative?: RelativeRoutingType;
|
|
44
|
-
}): string;
|
|
45
|
-
/**
|
|
46
|
-
* Returns true if this component is a descendant of a Router, useful to ensure
|
|
47
|
-
* a component is used within a Router.
|
|
48
|
-
*
|
|
49
|
-
* @category Hooks
|
|
50
|
-
*/
|
|
51
|
-
declare function useInRouterContext(): boolean;
|
|
52
|
-
/**
|
|
53
|
-
Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
|
|
54
|
-
|
|
55
|
-
```tsx
|
|
56
|
-
import * as React from 'react'
|
|
57
|
-
import { useLocation } from 'react-router'
|
|
58
|
-
|
|
59
|
-
function SomeComponent() {
|
|
60
|
-
let location = useLocation()
|
|
61
|
-
|
|
62
|
-
React.useEffect(() => {
|
|
63
|
-
// Google Analytics
|
|
64
|
-
ga('send', 'pageview')
|
|
65
|
-
}, [location]);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
// ...
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
@category Hooks
|
|
74
|
-
*/
|
|
75
|
-
declare function useLocation(): Location;
|
|
76
|
-
/**
|
|
77
|
-
* Returns the current navigation action which describes how the router came to
|
|
78
|
-
* the current location, either by a pop, push, or replace on the history stack.
|
|
79
|
-
*
|
|
80
|
-
* @category Hooks
|
|
81
|
-
*/
|
|
82
|
-
declare function useNavigationType(): Action;
|
|
83
|
-
/**
|
|
84
|
-
* Returns a PathMatch object if the given pattern matches the current URL.
|
|
85
|
-
* This is useful for components that need to know "active" state, e.g.
|
|
86
|
-
* `<NavLink>`.
|
|
87
|
-
*
|
|
88
|
-
* @category Hooks
|
|
89
|
-
*/
|
|
90
|
-
declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
|
|
91
|
-
/**
|
|
92
|
-
* The interface for the navigate() function returned from useNavigate().
|
|
93
|
-
*/
|
|
94
|
-
interface NavigateFunction {
|
|
95
|
-
(to: To, options?: NavigateOptions): void | Promise<void>;
|
|
96
|
-
(delta: number): void | Promise<void>;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
|
|
100
|
-
|
|
101
|
-
```tsx
|
|
102
|
-
import { useNavigate } from "react-router";
|
|
103
|
-
|
|
104
|
-
function SomeComponent() {
|
|
105
|
-
let navigate = useNavigate();
|
|
106
|
-
return (
|
|
107
|
-
<button
|
|
108
|
-
onClick={() => {
|
|
109
|
-
navigate(-1);
|
|
110
|
-
}}
|
|
111
|
-
/>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
|
|
117
|
-
|
|
118
|
-
@category Hooks
|
|
119
|
-
*/
|
|
120
|
-
declare function useNavigate(): NavigateFunction;
|
|
121
|
-
/**
|
|
122
|
-
* Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
|
|
123
|
-
*
|
|
124
|
-
* @category Hooks
|
|
125
|
-
*/
|
|
126
|
-
declare function useOutletContext<Context = unknown>(): Context;
|
|
127
|
-
/**
|
|
128
|
-
* Returns the element for the child route at this level of the route
|
|
129
|
-
* hierarchy. Used internally by `<Outlet>` to render child routes.
|
|
130
|
-
*
|
|
131
|
-
* @category Hooks
|
|
132
|
-
*/
|
|
133
|
-
declare function useOutlet(context?: unknown): React.ReactElement | null;
|
|
134
|
-
/**
|
|
135
|
-
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.
|
|
136
|
-
|
|
137
|
-
```tsx
|
|
138
|
-
import { useParams } from "react-router"
|
|
139
|
-
|
|
140
|
-
function SomeComponent() {
|
|
141
|
-
let params = useParams()
|
|
142
|
-
params.postId
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
|
|
147
|
-
|
|
148
|
-
@category Hooks
|
|
149
|
-
*/
|
|
150
|
-
declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
|
|
151
|
-
ParamsOrKey
|
|
152
|
-
] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
|
|
153
|
-
/**
|
|
154
|
-
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.
|
|
155
|
-
|
|
156
|
-
```tsx
|
|
157
|
-
import { useResolvedPath } from "react-router"
|
|
158
|
-
|
|
159
|
-
function SomeComponent() {
|
|
160
|
-
// if the user is at /dashboard/profile
|
|
161
|
-
let path = useResolvedPath("../accounts")
|
|
162
|
-
path.pathname // "/dashboard/accounts"
|
|
163
|
-
path.search // ""
|
|
164
|
-
path.hash // ""
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
@category Hooks
|
|
169
|
-
*/
|
|
170
|
-
declare function useResolvedPath(to: To, { relative }?: {
|
|
171
|
-
relative?: RelativeRoutingType;
|
|
172
|
-
}): Path;
|
|
173
|
-
/**
|
|
174
|
-
Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
|
|
175
|
-
|
|
176
|
-
The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
|
|
177
|
-
|
|
178
|
-
```tsx
|
|
179
|
-
import * as React from "react";
|
|
180
|
-
import { useRoutes } from "react-router";
|
|
181
|
-
|
|
182
|
-
function App() {
|
|
183
|
-
let element = useRoutes([
|
|
184
|
-
{
|
|
185
|
-
path: "/",
|
|
186
|
-
element: <Dashboard />,
|
|
187
|
-
children: [
|
|
188
|
-
{
|
|
189
|
-
path: "messages",
|
|
190
|
-
element: <DashboardMessages />,
|
|
191
|
-
},
|
|
192
|
-
{ path: "tasks", element: <DashboardTasks /> },
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
{ path: "team", element: <AboutPage /> },
|
|
196
|
-
]);
|
|
197
|
-
|
|
198
|
-
return element;
|
|
199
|
-
}
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
@category Hooks
|
|
203
|
-
*/
|
|
204
|
-
declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
|
|
205
|
-
/**
|
|
206
|
-
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.
|
|
207
|
-
|
|
208
|
-
```tsx
|
|
209
|
-
import { useNavigation } from "react-router"
|
|
210
|
-
|
|
211
|
-
function SomeComponent() {
|
|
212
|
-
let navigation = useNavigation();
|
|
213
|
-
navigation.state
|
|
214
|
-
navigation.formData
|
|
215
|
-
// etc.
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
@category Hooks
|
|
220
|
-
*/
|
|
221
|
-
declare function useNavigation(): Navigation;
|
|
222
|
-
/**
|
|
223
|
-
Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
|
|
224
|
-
|
|
225
|
-
```tsx
|
|
226
|
-
import { useRevalidator } from "react-router";
|
|
227
|
-
|
|
228
|
-
function WindowFocusRevalidator() {
|
|
229
|
-
const revalidator = useRevalidator();
|
|
230
|
-
|
|
231
|
-
useFakeWindowFocus(() => {
|
|
232
|
-
revalidator.revalidate();
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
return (
|
|
236
|
-
<div hidden={revalidator.state === "idle"}>
|
|
237
|
-
Revalidating...
|
|
238
|
-
</div>
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
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.
|
|
244
|
-
|
|
245
|
-
@category Hooks
|
|
246
|
-
*/
|
|
247
|
-
declare function useRevalidator(): {
|
|
248
|
-
revalidate: () => Promise<void>;
|
|
249
|
-
state: Router["state"]["revalidation"];
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* Returns the active route matches, useful for accessing loaderData for
|
|
253
|
-
* parent/child routes or the route "handle" property
|
|
254
|
-
*
|
|
255
|
-
* @category Hooks
|
|
256
|
-
*/
|
|
257
|
-
declare function useMatches(): UIMatch[];
|
|
258
|
-
/**
|
|
259
|
-
Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
|
|
260
|
-
|
|
261
|
-
```tsx
|
|
262
|
-
import { useLoaderData } from "react-router"
|
|
263
|
-
|
|
264
|
-
export async function loader() {
|
|
265
|
-
return await fakeDb.invoices.findAll();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export default function Invoices() {
|
|
269
|
-
let invoices = useLoaderData<typeof loader>();
|
|
270
|
-
// ...
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
@category Hooks
|
|
275
|
-
*/
|
|
276
|
-
declare function useLoaderData<T = any>(): SerializeFrom<T>;
|
|
277
|
-
/**
|
|
278
|
-
Returns the loader data for a given route by route ID.
|
|
279
|
-
|
|
280
|
-
```tsx
|
|
281
|
-
import { useRouteLoaderData } from "react-router";
|
|
282
|
-
|
|
283
|
-
function SomeComponent() {
|
|
284
|
-
const { user } = useRouteLoaderData("root");
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
|
|
289
|
-
|
|
290
|
-
| Route Filename | Route ID |
|
|
291
|
-
| -------------------------- | -------------------- |
|
|
292
|
-
| `app/root.tsx` | `"root"` |
|
|
293
|
-
| `app/routes/teams.tsx` | `"routes/teams"` |
|
|
294
|
-
| `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
|
|
295
|
-
|
|
296
|
-
If you created an ID manually, you can use that instead:
|
|
297
|
-
|
|
298
|
-
```tsx
|
|
299
|
-
route("/", "containers/app.tsx", { id: "app" }})
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
@category Hooks
|
|
303
|
-
*/
|
|
304
|
-
declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
|
|
305
|
-
/**
|
|
306
|
-
Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
|
|
307
|
-
|
|
308
|
-
```tsx
|
|
309
|
-
import { Form, useActionData } from "react-router"
|
|
310
|
-
|
|
311
|
-
export async function action({ request }) {
|
|
312
|
-
const body = await request.formData()
|
|
313
|
-
const name = body.get("visitorsName")
|
|
314
|
-
return { message: `Hello, ${name}` }
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export default function Invoices() {
|
|
318
|
-
const data = useActionData()
|
|
319
|
-
return (
|
|
320
|
-
<Form method="post">
|
|
321
|
-
<input type="text" name="visitorsName" />
|
|
322
|
-
{data ? data.message : "Waiting..."}
|
|
323
|
-
</Form>
|
|
324
|
-
)
|
|
325
|
-
}
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
@category Hooks
|
|
329
|
-
*/
|
|
330
|
-
declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
|
|
331
|
-
/**
|
|
332
|
-
Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
|
|
333
|
-
|
|
334
|
-
```tsx
|
|
335
|
-
export function ErrorBoundary() {
|
|
336
|
-
const error = useRouteError();
|
|
337
|
-
return <div>{error.message}</div>;
|
|
338
|
-
}
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
@category Hooks
|
|
342
|
-
*/
|
|
343
|
-
declare function useRouteError(): unknown;
|
|
344
|
-
/**
|
|
345
|
-
Returns the resolved promise value from the closest {@link Await | `<Await>`}.
|
|
346
|
-
|
|
347
|
-
```tsx
|
|
348
|
-
function SomeDescendant() {
|
|
349
|
-
const value = useAsyncValue();
|
|
350
|
-
// ...
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// somewhere in your app
|
|
354
|
-
<Await resolve={somePromise}>
|
|
355
|
-
<SomeDescendant />
|
|
356
|
-
</Await>
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
@category Hooks
|
|
360
|
-
*/
|
|
361
|
-
declare function useAsyncValue(): unknown;
|
|
362
|
-
/**
|
|
363
|
-
Returns the rejection value from the closest {@link Await | `<Await>`}.
|
|
364
|
-
|
|
365
|
-
```tsx
|
|
366
|
-
import { Await, useAsyncError } from "react-router"
|
|
367
|
-
|
|
368
|
-
function ErrorElement() {
|
|
369
|
-
const error = useAsyncError();
|
|
370
|
-
return (
|
|
371
|
-
<p>Uh Oh, something went wrong! {error.message}</p>
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// somewhere in your app
|
|
376
|
-
<Await
|
|
377
|
-
resolve={promiseThatRejects}
|
|
378
|
-
errorElement={<ErrorElement />}
|
|
379
|
-
/>
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
@category Hooks
|
|
383
|
-
*/
|
|
384
|
-
declare function useAsyncError(): unknown;
|
|
385
|
-
/**
|
|
386
|
-
* Allow the application to block navigations within the SPA and present the
|
|
387
|
-
* user a confirmation dialog to confirm the navigation. Mostly used to avoid
|
|
388
|
-
* using half-filled form data. This does not handle hard-reloads or
|
|
389
|
-
* cross-origin navigations.
|
|
390
|
-
*
|
|
391
|
-
* @category Hooks
|
|
392
|
-
*/
|
|
393
|
-
declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
|
|
394
|
-
|
|
395
28
|
interface StaticRouterProps {
|
|
396
29
|
basename?: string;
|
|
397
30
|
children?: React.ReactNode;
|
|
@@ -444,23 +77,9 @@ interface ServerRouterProps {
|
|
|
444
77
|
declare function ServerRouter({ context, url, nonce, }: ServerRouterProps): ReactElement;
|
|
445
78
|
|
|
446
79
|
interface StubRouteExtensions {
|
|
447
|
-
Component?:
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
actionData: ReturnType<typeof useActionData>;
|
|
451
|
-
matches: ReturnType<typeof useMatches>;
|
|
452
|
-
}>;
|
|
453
|
-
HydrateFallback?: React.ComponentType<{
|
|
454
|
-
params: ReturnType<typeof useParams>;
|
|
455
|
-
loaderData: ReturnType<typeof useLoaderData>;
|
|
456
|
-
actionData: ReturnType<typeof useActionData>;
|
|
457
|
-
}>;
|
|
458
|
-
ErrorBoundary?: React.ComponentType<{
|
|
459
|
-
params: ReturnType<typeof useParams>;
|
|
460
|
-
loaderData: ReturnType<typeof useLoaderData>;
|
|
461
|
-
actionData: ReturnType<typeof useActionData>;
|
|
462
|
-
error: ReturnType<typeof useRouteError>;
|
|
463
|
-
}>;
|
|
80
|
+
Component?: RouteComponentType;
|
|
81
|
+
HydrateFallback?: HydrateFallbackType;
|
|
82
|
+
ErrorBoundary?: ErrorBoundaryType;
|
|
464
83
|
loader?: LoaderFunction;
|
|
465
84
|
action?: ActionFunction;
|
|
466
85
|
children?: StubRouteObject[];
|
|
@@ -800,4 +419,4 @@ declare function getHydrationData(state: {
|
|
|
800
419
|
hasHydrateFallback: boolean;
|
|
801
420
|
}, location: Path, basename: string | undefined, isSpaMode: boolean): HydrationState;
|
|
802
421
|
|
|
803
|
-
export { ActionFunction, AppLoadContext,
|
|
422
|
+
export { ActionFunction, AppLoadContext, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, DataRouteObject, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, Location, MetaFunction, NonIndexRouteObject, PatchRoutesOnNavigationFunction, Path, type RequestHandler, RouteObject, RouterState, type RoutesTestStubProps, ServerBuild, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, 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, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, unstable_InitialContext, setDevServerHooks as unstable_setDevServerHooks };
|