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