UNPKG

51.2 kBTypeScriptView Raw
1import * as React from 'react';
2import { n as RouteObject, F as FutureConfig$1, H as HydrationState, I as InitialEntry, D as DataStrategyFunction, am as PatchRoutesOnNavigationFunction, a as Router$1, T as To, g as RelativeRoutingType, v as NonIndexRouteObject, a0 as LazyRouteFunction, u as IndexRouteObject, h as Location, i as Action, al as Navigator, ao as RouteMatch, r as StaticHandlerContext, d as RouteManifest, R as RouteModules, ak as DataRouteObject, aH as RouteModule, $ as HTMLFormMethod, Z as FormEncType, at as PageLinkDescriptor, aI as History, x as GetScrollRestorationKeyFunction, N as NavigateOptions, y as Fetcher, S as SerializeFrom, B as BlockerFunction } from './route-data-DuV3tXo2.js';
3
4/**
5 * @private
6 */
7declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
8 hasErrorBoundary: boolean;
9};
10/**
11 * @category Routers
12 */
13declare 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;
22interface RouterProviderProps {
23 router: Router$1;
24 flushSync?: (fn: () => unknown) => undefined;
25}
26/**
27 * Given a Remix Router instance, render the appropriate UI
28 */
29declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, }: RouterProviderProps): React.ReactElement;
30/**
31 * @category Types
32 */
33interface 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 */
44declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
45/**
46 * @category Types
47 */
48interface 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 */
63declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
64/**
65 * @category Types
66 */
67interface 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 */
97declare function Outlet(props: OutletProps): React.ReactElement | null;
98/**
99 * @category Types
100 */
101interface 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 */
123interface LayoutRouteProps extends PathRouteProps {
124}
125/**
126 * @category Types
127 */
128interface 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}
147type 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 */
156declare function Route$1(_props: RouteProps): React.ReactElement | null;
157/**
158 * @category Types
159 */
160interface 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 */
177declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
178/**
179 * @category Types
180 */
181interface 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 */
208declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
209interface AwaitResolveRenderFunction<Resolve = any> {
210 (data: Awaited<Resolve>): React.ReactNode;
211}
212/**
213 * @category Types
214 */
215interface 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<Resolve>;
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/**
315Used to render promise values with automatic error handling.
316
317```tsx
318import { Await, useLoaderData } from "react-router";
319
320export 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
328function 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*/
355declare 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 */
363declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
364/**
365 * Create route objects from JSX elements instead of arrays of objects
366 */
367declare let createRoutesFromElements: typeof createRoutesFromChildren;
368/**
369 * Renders the result of `matchRoutes()` into a React element.
370 *
371 * @category Utils
372 */
373declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
374
375type SerializedError = {
376 message: string;
377 stack?: string;
378};
379interface FrameworkContextObject {
380 manifest: AssetsManifest;
381 routeModules: RouteModules;
382 criticalCss?: string;
383 serverHandoffString?: string;
384 future: FutureConfig;
385 isSpaMode: boolean;
386 abortDelay?: number;
387 serializeError?(error: Error): SerializedError;
388 renderMeta?: {
389 didRenderScripts?: boolean;
390 streamCache?: Record<number, Promise<void> & {
391 result?: {
392 done: boolean;
393 value: string;
394 };
395 error?: unknown;
396 }>;
397 };
398}
399interface EntryContext extends FrameworkContextObject {
400 staticHandlerContext: StaticHandlerContext;
401 serverHandoffStream?: ReadableStream<Uint8Array>;
402}
403interface FutureConfig {
404}
405interface AssetsManifest {
406 entry: {
407 imports: string[];
408 module: string;
409 };
410 routes: RouteManifest<EntryRoute>;
411 url: string;
412 version: string;
413 hmr?: {
414 timestamp?: number;
415 runtime: string;
416 };
417}
418
419interface Route {
420 index?: boolean;
421 caseSensitive?: boolean;
422 id: string;
423 parentId?: string;
424 path?: string;
425}
426interface EntryRoute extends Route {
427 hasAction: boolean;
428 hasLoader: boolean;
429 hasClientAction: boolean;
430 hasClientLoader: boolean;
431 hasErrorBoundary: boolean;
432 imports?: string[];
433 css?: string[];
434 module: string;
435 parentId?: string;
436}
437declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, future: FutureConfig, isSpaMode: boolean): DataRouteObject[];
438declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
439declare function shouldHydrateRouteLoader(route: EntryRoute, routeModule: RouteModule, isSpaMode: boolean): boolean;
440
441type ParamKeyValuePair = [string, string];
442type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
443/**
444 Creates a URLSearchParams object using the given initializer.
445
446 This is identical to `new URLSearchParams(init)` except it also
447 supports arrays as values in the object form of the initializer
448 instead of just strings. This is convenient when you need multiple
449 values for a given key, but don't want to use an array initializer.
450
451 For example, instead of:
452
453 ```tsx
454 let searchParams = new URLSearchParams([
455 ['sort', 'name'],
456 ['sort', 'price']
457 ]);
458 ```
459 you can do:
460
461 ```
462 let searchParams = createSearchParams({
463 sort: ['name', 'price']
464 });
465 ```
466
467 @category Utils
468 */
469declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
470type JsonObject = {
471 [Key in string]: JsonValue;
472} & {
473 [Key in string]?: JsonValue | undefined;
474};
475type JsonArray = JsonValue[] | readonly JsonValue[];
476type JsonPrimitive = string | number | boolean | null;
477type JsonValue = JsonPrimitive | JsonObject | JsonArray;
478type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
479/**
480 * Submit options shared by both navigations and fetchers
481 */
482interface SharedSubmitOptions {
483 /**
484 * The HTTP method used to submit the form. Overrides `<form method>`.
485 * Defaults to "GET".
486 */
487 method?: HTMLFormMethod;
488 /**
489 * The action URL path used to submit the form. Overrides `<form action>`.
490 * Defaults to the path of the current route.
491 */
492 action?: string;
493 /**
494 * The encoding used to submit the form. Overrides `<form encType>`.
495 * Defaults to "application/x-www-form-urlencoded".
496 */
497 encType?: FormEncType;
498 /**
499 * Determines whether the form action is relative to the route hierarchy or
500 * the pathname. Use this if you want to opt out of navigating the route
501 * hierarchy and want to instead route based on /-delimited URL segments
502 */
503 relative?: RelativeRoutingType;
504 /**
505 * In browser-based environments, prevent resetting scroll after this
506 * navigation when using the <ScrollRestoration> component
507 */
508 preventScrollReset?: boolean;
509 /**
510 * Enable flushSync for this submission's state updates
511 */
512 flushSync?: boolean;
513}
514/**
515 * Submit options available to fetchers
516 */
517interface FetcherSubmitOptions extends SharedSubmitOptions {
518}
519/**
520 * Submit options available to navigations
521 */
522interface SubmitOptions extends FetcherSubmitOptions {
523 /**
524 * Set `true` to replace the current entry in the browser's history stack
525 * instead of creating a new one (i.e. stay on "the same page"). Defaults
526 * to `false`.
527 */
528 replace?: boolean;
529 /**
530 * State object to add to the history stack entry for this navigation
531 */
532 state?: any;
533 /**
534 * Indicate a specific fetcherKey to use when using navigate=false
535 */
536 fetcherKey?: string;
537 /**
538 * navigate=false will use a fetcher instead of a navigation
539 */
540 navigate?: boolean;
541 /**
542 * Enable view transitions on this submission navigation
543 */
544 viewTransition?: boolean;
545}
546
547declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
548/**
549 * Defines the discovery behavior of the link:
550 *
551 * - "render" - default, discover the route when the link renders
552 * - "none" - don't eagerly discover, only discover if the link is clicked
553 */
554type DiscoverBehavior = "render" | "none";
555/**
556 * Defines the prefetching behavior of the link:
557 *
558 * - "none": Never fetched
559 * - "intent": Fetched when the user focuses or hovers the link
560 * - "render": Fetched when the link is rendered
561 * - "viewport": Fetched when the link is in the viewport
562 */
563type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
564/**
565 Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
566
567 ```tsx
568 import { Links } from "react-router";
569
570 export default function Root() {
571 return (
572 <html>
573 <head>
574 <Links />
575 </head>
576 <body></body>
577 </html>
578 );
579 }
580 ```
581
582 @category Components
583 */
584declare function Links(): React.JSX.Element;
585/**
586 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.
587
588 ```tsx
589 import { PrefetchPageLinks } from "react-router"
590
591 <PrefetchPageLinks page="/absolute/path" />
592 ```
593
594 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.
595
596 @category Components
597 */
598declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
599/**
600 Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
601
602 ```tsx
603 import { Meta } from "react-router";
604
605 export default function Root() {
606 return (
607 <html>
608 <head>
609 <Meta />
610 </head>
611 </html>
612 );
613 }
614 ```
615
616 @category Components
617 */
618declare function Meta(): React.JSX.Element;
619/**
620 A couple common attributes:
621
622 - `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
623 - `<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.
624
625 You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
626
627 @category Types
628 */
629type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
630/**
631 Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
632
633 ```tsx
634 import { Scripts } from "react-router";
635
636 export default function Root() {
637 return (
638 <html>
639 <head />
640 <body>
641 <Scripts />
642 </body>
643 </html>
644 );
645 }
646 ```
647
648 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.
649
650 @category Components
651 */
652declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
653
654declare global {
655 const REACT_ROUTER_VERSION: string;
656}
657interface DOMRouterOpts {
658 basename?: string;
659 future?: Partial<FutureConfig$1>;
660 hydrationData?: HydrationState;
661 dataStrategy?: DataStrategyFunction;
662 patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
663 window?: Window;
664}
665/**
666 * @category Routers
667 */
668declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
669/**
670 * @category Routers
671 */
672declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router$1;
673/**
674 * @category Types
675 */
676interface BrowserRouterProps {
677 basename?: string;
678 children?: React.ReactNode;
679 window?: Window;
680}
681/**
682 * A `<Router>` for use in web browsers. Provides the cleanest URLs.
683 *
684 * @category Router Components
685 */
686declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): React.JSX.Element;
687/**
688 * @category Types
689 */
690interface HashRouterProps {
691 basename?: string;
692 children?: React.ReactNode;
693 window?: Window;
694}
695/**
696 * A `<Router>` for use in web browsers. Stores the location in the hash
697 * portion of the URL so it is not sent to the server.
698 *
699 * @category Router Components
700 */
701declare function HashRouter({ basename, children, window }: HashRouterProps): React.JSX.Element;
702/**
703 * @category Types
704 */
705interface HistoryRouterProps {
706 basename?: string;
707 children?: React.ReactNode;
708 history: History;
709}
710/**
711 * A `<Router>` that accepts a pre-instantiated history object. It's important
712 * to note that using your own history object is highly discouraged and may add
713 * two versions of the history library to your bundles unless you use the same
714 * version of the history library that React Router uses internally.
715 *
716 * @name unstable_HistoryRouter
717 * @category Router Components
718 */
719declare function HistoryRouter({ basename, children, history, }: HistoryRouterProps): React.JSX.Element;
720declare namespace HistoryRouter {
721 var displayName: string;
722}
723/**
724 * @category Types
725 */
726interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
727 /**
728 Defines the link discovery behavior
729
730 ```tsx
731 <Link /> // default ("render")
732 <Link discover="render" />
733 <Link discover="none" />
734 ```
735
736 - **render** - default, discover the route when the link renders
737 - **none** - don't eagerly discover, only discover if the link is clicked
738 */
739 discover?: DiscoverBehavior;
740 /**
741 Defines the data and module prefetching behavior for the link.
742
743 ```tsx
744 <Link /> // default
745 <Link prefetch="none" />
746 <Link prefetch="intent" />
747 <Link prefetch="render" />
748 <Link prefetch="viewport" />
749 ```
750
751 - **none** - default, no prefetching
752 - **intent** - prefetches when the user hovers or focuses the link
753 - **render** - prefetches when the link renders
754 - **viewport** - prefetches when the link is in the viewport, very useful for mobile
755
756 Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
757
758 ```tsx
759 <a href="..." />
760 <a href="..." />
761 <link rel="prefetch" /> // might conditionally render
762 ```
763
764 Because of this, if you are using `nav :last-child` you will need to use `nav :last-of-type` so the styles don't conditionally fall off your last link (and any other similar selectors).
765 */
766 prefetch?: PrefetchBehavior;
767 /**
768 Will use document navigation instead of client side routing when the link is clicked: the browser will handle the transition normally (as if it were an `<a href>`).
769
770 ```tsx
771 <Link to="/logout" reloadDocument />
772 ```
773 */
774 reloadDocument?: boolean;
775 /**
776 Replaces the current entry in the history stack instead of pushing a new one onto it.
777
778 ```tsx
779 <Link replace />
780 ```
781
782 ```
783 # with a history stack like this
784 A -> B
785
786 # normal link click pushes a new entry
787 A -> B -> C
788
789 # but with `replace`, B is replaced by C
790 A -> C
791 ```
792 */
793 replace?: boolean;
794 /**
795 Adds persistent client side routing state to the next location.
796
797 ```tsx
798 <Link to="/somewhere/else" state={{ some: "value" }} />
799 ```
800
801 The location state is accessed from the `location`.
802
803 ```tsx
804 function SomeComp() {
805 const location = useLocation()
806 location.state; // { some: "value" }
807 }
808 ```
809
810 This state is inaccessible on the server as it is implemented on top of [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
811 */
812 state?: any;
813 /**
814 Prevents the scroll position from being reset to the top of the window when the link is clicked and the app is using {@link ScrollRestoration}. This only prevents new locations reseting scroll to the top, scroll position will be restored for back/forward button navigation.
815
816 ```tsx
817 <Link to="?tab=one" preventScrollReset />
818 ```
819 */
820 preventScrollReset?: boolean;
821 /**
822 Defines the relative path behavior for the link.
823
824 ```tsx
825 <Link to=".." /> // default: "route"
826 <Link relative="route" />
827 <Link relative="path" />
828 ```
829
830 Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
831
832 - **route** - default, resolves the link relative to the route pattern. In the example above a relative link of `".."` will remove both `:slug/edit` segments back to "/blog".
833 - **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
834 */
835 relative?: RelativeRoutingType;
836 /**
837 Can be a string or a partial {@link Path}:
838
839 ```tsx
840 <Link to="/some/path" />
841
842 <Link
843 to={{
844 pathname: "/some/path",
845 search: "?query=string",
846 hash: "#hash",
847 }}
848 />
849 ```
850 */
851 to: To;
852 /**
853 Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
854
855 ```jsx
856 <Link to={to} viewTransition>
857 Click me
858 </Link>
859 ```
860
861 To apply specific styles for the transition, see {@link useViewTransitionState}
862 */
863 viewTransition?: boolean;
864}
865/**
866 A progressively enhanced `<a href>` wrapper to enable navigation with client-side routing.
867
868 ```tsx
869 import { Link } from "react-router";
870
871 <Link to="/dashboard">Dashboard</Link>;
872
873 <Link
874 to={{
875 pathname: "/some/path",
876 search: "?query=string",
877 hash: "#hash",
878 }}
879 />
880 ```
881
882 @category Components
883 */
884declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
885/**
886 The object passed to {@link NavLink} `children`, `className`, and `style` prop callbacks to render and style the link based on its state.
887
888 ```
889 // className
890 <NavLink
891 to="/messages"
892 className={({ isActive, isPending }) =>
893 isPending ? "pending" : isActive ? "active" : ""
894 }
895 >
896 Messages
897 </NavLink>
898
899 // style
900 <NavLink
901 to="/messages"
902 style={({ isActive, isPending }) => {
903 return {
904 fontWeight: isActive ? "bold" : "",
905 color: isPending ? "red" : "black",
906 }
907 )}
908 />
909
910 // children
911 <NavLink to="/tasks">
912 {({ isActive, isPending }) => (
913 <span className={isActive ? "active" : ""}>Tasks</span>
914 )}
915 </NavLink>
916 ```
917
918 */
919type NavLinkRenderProps = {
920 /**
921 * Indicates if the link's URL matches the current location.
922 */
923 isActive: boolean;
924 /**
925 * Indicates if the pending location matches the link's URL.
926 */
927 isPending: boolean;
928 /**
929 * Indicates if a view transition to the link's URL is in progress. See {@link useViewTransitionState}
930 */
931 isTransitioning: boolean;
932};
933/**
934 * @category Types
935 */
936interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
937 /**
938 Can be regular React children or a function that receives an object with the active and pending states of the link.
939
940 ```tsx
941 <NavLink to="/tasks">
942 {({ isActive }) => (
943 <span className={isActive ? "active" : ""}>Tasks</span>
944 )}
945 </NavLink>
946 ```
947 */
948 children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
949 /**
950 Changes the matching logic to make it case-sensitive:
951
952 | Link | URL | isActive |
953 | -------------------------------------------- | ------------- | -------- |
954 | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
955 | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
956 */
957 caseSensitive?: boolean;
958 /**
959 Classes are automatically applied to NavLink that correspond to {@link NavLinkRenderProps}.
960
961 ```css
962 a.active { color: red; }
963 a.pending { color: blue; }
964 a.transitioning {
965 view-transition-name: my-transition;
966 }
967 ```
968 */
969 className?: string | ((props: NavLinkRenderProps) => string | undefined);
970 /**
971 Changes the matching logic for the `active` and `pending` states to only match to the "end" of the {@link NavLinkProps.to}. If the URL is longer, it will no longer be considered active.
972
973 | Link | URL | isActive |
974 | ----------------------------- | ------------ | -------- |
975 | `<NavLink to="/tasks" />` | `/tasks` | true |
976 | `<NavLink to="/tasks" />` | `/tasks/123` | true |
977 | `<NavLink to="/tasks" end />` | `/tasks` | true |
978 | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
979
980 `<NavLink to="/">` is an exceptional case because _every_ URL matches `/`. To avoid this matching every single route by default, it effectively ignores the `end` prop and only matches when you're at the root route.
981 */
982 end?: boolean;
983 style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
984}
985/**
986 Wraps {@link Link | `<Link>`} with additional props for styling active and pending states.
987
988 - Automatically applies classes to the link based on its active and pending states, see {@link NavLinkProps.className}.
989 - Automatically applies `aria-current="page"` to the link when the link is active. See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current) on MDN.
990
991 ```tsx
992 import { NavLink } from "react-router"
993 <NavLink to="/message" />
994 ```
995
996 States are available through the className, style, and children render props. See {@link NavLinkRenderProps}.
997
998 ```tsx
999 <NavLink
1000 to="/messages"
1001 className={({ isActive, isPending }) =>
1002 isPending ? "pending" : isActive ? "active" : ""
1003 }
1004 >
1005 Messages
1006 </NavLink>
1007 ```
1008
1009 @category Components
1010 */
1011declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
1012/**
1013 * Form props shared by navigations and fetchers
1014 */
1015interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
1016 /**
1017 * The HTTP verb to use when the form is submitted. Supports "get", "post",
1018 * "put", "delete", and "patch".
1019 *
1020 * Native `<form>` only supports `get` and `post`, avoid the other verbs if
1021 * you'd like to support progressive enhancement
1022 */
1023 method?: HTMLFormMethod;
1024 /**
1025 * The encoding type to use for the form submission.
1026 */
1027 encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
1028 /**
1029 * The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
1030 */
1031 action?: string;
1032 /**
1033 * Determines whether the form action is relative to the route hierarchy or
1034 * the pathname. Use this if you want to opt out of navigating the route
1035 * hierarchy and want to instead route based on /-delimited URL segments
1036 */
1037 relative?: RelativeRoutingType;
1038 /**
1039 * Prevent the scroll position from resetting to the top of the viewport on
1040 * completion of the navigation when using the <ScrollRestoration> component
1041 */
1042 preventScrollReset?: boolean;
1043 /**
1044 * A function to call when the form is submitted. If you call
1045 * `event.preventDefault()` then this form will not do anything.
1046 */
1047 onSubmit?: React.FormEventHandler<HTMLFormElement>;
1048}
1049/**
1050 * Form props available to fetchers
1051 * @category Types
1052 */
1053interface FetcherFormProps extends SharedFormProps {
1054}
1055/**
1056 * Form props available to navigations
1057 * @category Types
1058 */
1059interface FormProps extends SharedFormProps {
1060 discover?: DiscoverBehavior;
1061 /**
1062 * Indicates a specific fetcherKey to use when using `navigate={false}` so you
1063 * can pick up the fetcher's state in a different component in a {@link
1064 * useFetcher}.
1065 */
1066 fetcherKey?: string;
1067 /**
1068 * Skips the navigation and uses a {@link useFetcher | fetcher} internally
1069 * when `false`. This is essentially a shorthand for `useFetcher()` +
1070 * `<fetcher.Form>` where you don't care about the resulting data in this
1071 * component.
1072 */
1073 navigate?: boolean;
1074 /**
1075 * Forces a full document navigation instead of client side routing + data
1076 * fetch.
1077 */
1078 reloadDocument?: boolean;
1079 /**
1080 * Replaces the current entry in the browser history stack when the form
1081 * navigates. Use this if you don't want the user to be able to click "back"
1082 * to the page with the form on it.
1083 */
1084 replace?: boolean;
1085 /**
1086 * State object to add to the history stack entry for this navigation
1087 */
1088 state?: any;
1089 /**
1090 * Enables a [View
1091 * Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
1092 * for this navigation. To apply specific styles during the transition see
1093 * {@link useViewTransitionState}.
1094 */
1095 viewTransition?: boolean;
1096}
1097/**
1098
1099A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) that submits data to actions via `fetch`, activating pending states in `useNavigation` which enables advanced user interfaces beyond a basic HTML form. After a form's action completes, all data on the page is automatically revalidated to keep the UI in sync with the data.
1100
1101Because it uses the HTML form API, server rendered pages are interactive at a basic level before JavaScript loads. Instead of React Router managing the submission, the browser manages the submission as well as the pending states (like the spinning favicon). After JavaScript loads, React Router takes over enabling web application user experiences.
1102
1103Form is most useful for submissions that should also change the URL or otherwise add an entry to the browser history stack. For forms that shouldn't manipulate the browser history stack, use [`<fetcher.Form>`][fetcher_form].
1104
1105```tsx
1106import { Form } from "react-router";
1107
1108function NewEvent() {
1109 return (
1110 <Form action="/events" method="post">
1111 <input name="title" type="text" />
1112 <input name="description" type="text" />
1113 </Form>
1114 )
1115}
1116```
1117
1118@category Components
1119*/
1120declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
1121type ScrollRestorationProps = ScriptsProps & {
1122 /**
1123 Defines the key used to restore scroll positions.
1124
1125 ```tsx
1126 <ScrollRestoration
1127 getKey={(location, matches) => {
1128 // default behavior
1129 return location.key
1130 }}
1131 />
1132 ```
1133 */
1134 getKey?: GetScrollRestorationKeyFunction;
1135 storageKey?: string;
1136};
1137/**
1138 Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
1139
1140 ```tsx
1141 import { ScrollRestoration } from "react-router";
1142
1143 export default function Root() {
1144 return (
1145 <html>
1146 <body>
1147 <ScrollRestoration />
1148 <Scripts />
1149 </body>
1150 </html>
1151 );
1152 }
1153 ```
1154
1155 This component renders an inline `<script>` to prevent scroll flashing. The `nonce` prop will be passed down to the script tag to allow CSP nonce usage.
1156
1157 ```tsx
1158 <ScrollRestoration nonce={cspNonce} />
1159 ```
1160
1161 @category Components
1162 */
1163declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
1164declare namespace ScrollRestoration {
1165 var displayName: string;
1166}
1167/**
1168 * Handles the click behavior for router `<Link>` components. This is useful if
1169 * you need to create custom `<Link>` components with the same click behavior we
1170 * use in our exported `<Link>`.
1171 *
1172 * @category Hooks
1173 */
1174declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
1175 target?: React.HTMLAttributeAnchorTarget;
1176 replace?: boolean;
1177 state?: any;
1178 preventScrollReset?: boolean;
1179 relative?: RelativeRoutingType;
1180 viewTransition?: boolean;
1181}): (event: React.MouseEvent<E, MouseEvent>) => void;
1182/**
1183 Returns a tuple of the current URL's {@link URLSearchParams} and a function to update them. Setting the search params causes a navigation.
1184
1185 ```tsx
1186 import { useSearchParams } from "react-router";
1187
1188 export function SomeComponent() {
1189 const [searchParams, setSearchParams] = useSearchParams();
1190 // ...
1191 }
1192 ```
1193
1194 @category Hooks
1195 */
1196declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
1197/**
1198 Sets new search params and causes a navigation when called.
1199
1200 ```tsx
1201 <button
1202 onClick={() => {
1203 const params = new URLSearchParams();
1204 params.set("someKey", "someValue");
1205 setSearchParams(params, {
1206 preventScrollReset: true,
1207 });
1208 }}
1209 />
1210 ```
1211
1212 It also supports a function for setting new search params.
1213
1214 ```tsx
1215 <button
1216 onClick={() => {
1217 setSearchParams((prev) => {
1218 prev.set("someKey", "someValue");
1219 return prev;
1220 });
1221 }}
1222 />
1223 ```
1224 */
1225type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
1226/**
1227 * Submits a HTML `<form>` to the server without reloading the page.
1228 */
1229interface SubmitFunction {
1230 (
1231 /**
1232 Can be multiple types of elements and objects
1233
1234 **`HTMLFormElement`**
1235
1236 ```tsx
1237 <Form
1238 onSubmit={(event) => {
1239 submit(event.currentTarget);
1240 }}
1241 />
1242 ```
1243
1244 **`FormData`**
1245
1246 ```tsx
1247 const formData = new FormData();
1248 formData.append("myKey", "myValue");
1249 submit(formData, { method: "post" });
1250 ```
1251
1252 **Plain object that will be serialized as `FormData`**
1253
1254 ```tsx
1255 submit({ myKey: "myValue" }, { method: "post" });
1256 ```
1257
1258 **Plain object that will be serialized as JSON**
1259
1260 ```tsx
1261 submit(
1262 { myKey: "myValue" },
1263 { method: "post", encType: "application/json" }
1264 );
1265 ```
1266 */
1267 target: SubmitTarget,
1268 /**
1269 * Options that override the `<form>`'s own attributes. Required when
1270 * submitting arbitrary data without a backing `<form>`.
1271 */
1272 options?: SubmitOptions): Promise<void>;
1273}
1274/**
1275 * Submits a fetcher `<form>` to the server without reloading the page.
1276 */
1277interface FetcherSubmitFunction {
1278 (
1279 /**
1280 Can be multiple types of elements and objects
1281
1282 **`HTMLFormElement`**
1283
1284 ```tsx
1285 <fetcher.Form
1286 onSubmit={(event) => {
1287 fetcher.submit(event.currentTarget);
1288 }}
1289 />
1290 ```
1291
1292 **`FormData`**
1293
1294 ```tsx
1295 const formData = new FormData();
1296 formData.append("myKey", "myValue");
1297 fetcher.submit(formData, { method: "post" });
1298 ```
1299
1300 **Plain object that will be serialized as `FormData`**
1301
1302 ```tsx
1303 fetcher.submit({ myKey: "myValue" }, { method: "post" });
1304 ```
1305
1306 **Plain object that will be serialized as JSON**
1307
1308 ```tsx
1309 fetcher.submit(
1310 { myKey: "myValue" },
1311 { method: "post", encType: "application/json" }
1312 );
1313 ```
1314
1315 */
1316 target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
1317}
1318/**
1319 The imperative version of {@link Form | `<Form>`} that lets you submit a form from code instead of a user interaction.
1320
1321 ```tsx
1322 import { useSubmit } from "react-router";
1323
1324 function SomeComponent() {
1325 const submit = useSubmit();
1326 return (
1327 <Form
1328 onChange={(event) => {
1329 submit(event.currentTarget);
1330 }}
1331 />
1332 );
1333 }
1334 ```
1335
1336 @category Hooks
1337 */
1338declare function useSubmit(): SubmitFunction;
1339/**
1340 Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.
1341
1342 This is used internally by {@link Form} resolve the action to the closest route, but can be used generically as well.
1343
1344 ```tsx
1345 import { useFormAction } from "react-router";
1346
1347 function SomeComponent() {
1348 // closest route URL
1349 let action = useFormAction();
1350
1351 // closest route URL + "destroy"
1352 let destroyAction = useFormAction("destroy");
1353 }
1354 ```
1355
1356 @category Hooks
1357 */
1358declare function useFormAction(
1359/**
1360 * The action to append to the closest route URL.
1361 */
1362action?: string, { relative }?: {
1363 relative?: RelativeRoutingType;
1364}): string;
1365/**
1366The return value of `useFetcher` that keeps track of the state of a fetcher.
1367
1368```tsx
1369let fetcher = useFetcher();
1370```
1371 */
1372type FetcherWithComponents<TData> = Fetcher<TData> & {
1373 /**
1374 Just like {@link Form} except it doesn't cause a navigation.
1375
1376 ```tsx
1377 function SomeComponent() {
1378 const fetcher = useFetcher()
1379 return (
1380 <fetcher.Form method="post" action="/some/route">
1381 <input type="text" />
1382 </fetcher.Form>
1383 )
1384 }
1385 ```
1386 */
1387 Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
1388 /**
1389 Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
1390
1391 The `formData` can be multiple types:
1392
1393 - [`FormData`][form_data] - A `FormData` instance.
1394 - [`HTMLFormElement`][html_form_element] - A [`<form>`][form_element] DOM element.
1395 - `Object` - An object of key/value pairs that will be converted to a `FormData` instance by default. You can pass a more complex object and serialize it as JSON by specifying `encType: "application/json"`. See [`useSubmit`][use-submit] for more details.
1396
1397 If the method is `GET`, then the route [`loader`][loader] is being called and with the `formData` serialized to the url as [`URLSearchParams`][url_search_params]. If `DELETE`, `PATCH`, `POST`, or `PUT`, then the route [`action`][action] is being called with `formData` as the body.
1398
1399 ```tsx
1400 // Submit a FormData instance (GET request)
1401 const formData = new FormData();
1402 fetcher.submit(formData);
1403
1404 // Submit the HTML form element
1405 fetcher.submit(event.currentTarget.form, {
1406 method: "POST",
1407 });
1408
1409 // Submit key/value JSON as a FormData instance
1410 fetcher.submit(
1411 { serialized: "values" },
1412 { method: "POST" }
1413 );
1414
1415 // Submit raw JSON
1416 fetcher.submit(
1417 {
1418 deeply: {
1419 nested: {
1420 json: "values",
1421 },
1422 },
1423 },
1424 {
1425 method: "POST",
1426 encType: "application/json",
1427 }
1428 );
1429 ```
1430 */
1431 submit: FetcherSubmitFunction;
1432 /**
1433 Loads data from a route. Useful for loading data imperatively inside of user events outside of a normal button or form, like a combobox or search input.
1434
1435 ```tsx
1436 let fetcher = useFetcher()
1437
1438 <input onChange={e => {
1439 fetcher.load(`/search?q=${e.target.value}`)
1440 }} />
1441 ```
1442 */
1443 load: (href: string, opts?: {
1444 /**
1445 * Wraps the initial state update for this `fetcher.load` in a
1446 * `ReactDOM.flushSync` call instead of the default `React.startTransition`.
1447 * This allows you to perform synchronous DOM actions immediately after the
1448 * update is flushed to the DOM.
1449 */
1450 flushSync?: boolean;
1451 }) => Promise<void>;
1452};
1453/**
1454 Useful for creating complex, dynamic user interfaces that require multiple, concurrent data interactions without causing a navigation.
1455
1456 Fetchers track their own, independent state and can be used to load data, submit forms, and generally interact with loaders and actions.
1457
1458 ```tsx
1459 import { useFetcher } from "react-router"
1460
1461 function SomeComponent() {
1462 let fetcher = useFetcher()
1463
1464 // states are available on the fetcher
1465 fetcher.state // "idle" | "loading" | "submitting"
1466 fetcher.data // the data returned from the action or loader
1467
1468 // render a form
1469 <fetcher.Form method="post" />
1470
1471 // load data
1472 fetcher.load("/some/route")
1473
1474 // submit data
1475 fetcher.submit(someFormRef, { method: "post" })
1476 fetcher.submit(someData, {
1477 method: "post",
1478 encType: "application/json"
1479 })
1480 }
1481 ```
1482
1483 @category Hooks
1484 */
1485declare function useFetcher<T = any>({ key, }?: {
1486 /**
1487 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:
1488
1489 ```tsx
1490 function SomeComp() {
1491 let fetcher = useFetcher({ key: "my-key" })
1492 // ...
1493 }
1494
1495 // Somewhere else
1496 function AnotherComp() {
1497 // this will be the same fetcher, sharing the state across the app
1498 let fetcher = useFetcher({ key: "my-key" });
1499 // ...
1500 }
1501 ```
1502 */
1503 key?: string;
1504}): FetcherWithComponents<SerializeFrom<T>>;
1505/**
1506 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.
1507
1508 ```tsx
1509 import { useFetchers } from "react-router";
1510
1511 function SomeComponent() {
1512 const fetchers = useFetchers();
1513 fetchers[0].formData; // FormData
1514 fetchers[0].state; // etc.
1515 // ...
1516 }
1517 ```
1518
1519 @category Hooks
1520 */
1521declare function useFetchers(): (Fetcher & {
1522 key: string;
1523})[];
1524/**
1525 * When rendered inside a RouterProvider, will restore scroll positions on navigations
1526 */
1527declare function useScrollRestoration({ getKey, storageKey, }?: {
1528 getKey?: GetScrollRestorationKeyFunction;
1529 storageKey?: string;
1530}): void;
1531/**
1532 * Setup a callback to be fired on the window's `beforeunload` event.
1533 *
1534 * @category Hooks
1535 */
1536declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
1537 capture?: boolean;
1538}): void;
1539/**
1540 Wrapper around useBlocker to show a window.confirm prompt to users instead of building a custom UI with {@link useBlocker}.
1541
1542 The `unstable_` flag will not be removed because this technique has a lot of rough edges and behaves very differently (and incorrectly sometimes) across browsers if users click addition back/forward navigations while the confirmation is open. Use at your own risk.
1543
1544 ```tsx
1545 function ImportantForm() {
1546 let [value, setValue] = React.useState("");
1547
1548 // Block navigating elsewhere when data has been entered into the input
1549 unstable_usePrompt({
1550 message: "Are you sure?",
1551 when: ({ currentLocation, nextLocation }) =>
1552 value !== "" &&
1553 currentLocation.pathname !== nextLocation.pathname,
1554 });
1555
1556 return (
1557 <Form method="post">
1558 <label>
1559 Enter some important data:
1560 <input
1561 name="data"
1562 value={value}
1563 onChange={(e) => setValue(e.target.value)}
1564 />
1565 </label>
1566 <button type="submit">Save</button>
1567 </Form>
1568 );
1569 }
1570 ```
1571
1572 @category Hooks
1573 @name unstable_usePrompt
1574 */
1575declare function usePrompt({ when, message, }: {
1576 when: boolean | BlockerFunction;
1577 message: string;
1578}): void;
1579/**
1580 This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) to the specified location. This can be used to apply finer-grained styles to elements to further customize the view transition. This requires that view transitions have been enabled for the given navigation via {@link LinkProps.viewTransition} (or the `Form`, `submit`, or `navigate` call)
1581
1582 @category Hooks
1583 @name useViewTransitionState
1584 */
1585declare function useViewTransitionState(to: To, opts?: {
1586 relative?: RelativeRoutingType;
1587}): boolean;
1588
1589declare global {
1590 interface Navigator {
1591 connection?: {
1592 saveData: boolean;
1593 };
1594 }
1595}
1596declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
1597declare function useFogOFWarDiscovery(router: Router$1, manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean): void;
1598
1599export { useFetcher as $, type AssetsManifest as A, type BrowserRouterProps as B, type FetcherWithComponents as C, createBrowserRouter as D, type EntryContext as E, type FutureConfig as F, createHashRouter as G, type HashRouterProps as H, type IndexRouteProps as I, BrowserRouter as J, HashRouter as K, type LayoutRouteProps as L, type MemoryRouterProps as M, type NavigateProps as N, type OutletProps as O, type PathRouteProps as P, Link as Q, type RouterProviderProps as R, type ScrollRestorationProps as S, HistoryRouter as T, NavLink as U, Form as V, ScrollRestoration as W, useLinkClickHandler as X, useSearchParams as Y, useSubmit as Z, useFormAction as _, type Route as a, useFetchers as a0, useBeforeUnload as a1, usePrompt as a2, useViewTransitionState as a3, type FetcherSubmitOptions as a4, type ParamKeyValuePair as a5, type SubmitOptions as a6, type URLSearchParamsInit as a7, type SubmitTarget as a8, createSearchParams as a9, Meta as aa, Links as ab, Scripts as ac, PrefetchPageLinks as ad, type ScriptsProps as ae, mapRouteProperties as af, FrameworkContext as ag, getPatchRoutesOnNavigationFunction as ah, useFogOFWarDiscovery as ai, createClientRoutes as aj, createClientRoutesWithHMRRevalidationOptOut as ak, shouldHydrateRouteLoader as al, useScrollRestoration as am, 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, createRoutesFromElements as p, type HistoryRouterProps as q, renderMatches as r, type LinkProps as s, type NavLinkProps as t, type NavLinkRenderProps as u, type FetcherFormProps as v, type FormProps as w, type SetURLSearchParams as x, type SubmitFunction as y, type FetcherSubmitFunction as z };
1600
\No newline at end of file