| 1 | import { bG as RouteManifest, o as RouteModules, Q as HydrationState, a1 as DataRouteObject, a as ClientLoaderFunction, a5 as StaticHandlerContext, bH as ServerRouteModule, q as MiddlewareEnabled, c as RouterContextProvider, r as AppLoadContext, al as LoaderFunctionArgs, ac as ActionFunctionArgs, au as unstable_ServerInstrumentation, aj as HTMLFormMethod, ah as FormEncType, w as RelativeRoutingType, bh as PageLinkDescriptor, T as To, bI as History, a4 as GetScrollRestorationKeyFunction, e as RouterInit, bJ as FutureConfig$1, u as unstable_ClientInstrumentation, p as DataStrategyFunction, a0 as PatchRoutesOnNavigationFunction, s as NavigateOptions, a6 as Fetcher, K as RouteObject, n as Router, v as SerializeFrom, B as BlockerFunction, L as Location, bK as CreateStaticHandlerOptions$1, a2 as StaticHandler } from './instrumentation--6Pioq_G.js';
|
| 2 | import * as React from 'react';
|
| 3 |
|
| 4 | interface Route {
|
| 5 | index?: boolean;
|
| 6 | caseSensitive?: boolean;
|
| 7 | id: string;
|
| 8 | parentId?: string;
|
| 9 | path?: string;
|
| 10 | }
|
| 11 | interface EntryRoute extends Route {
|
| 12 | hasAction: boolean;
|
| 13 | hasLoader: boolean;
|
| 14 | hasClientAction: boolean;
|
| 15 | hasClientLoader: boolean;
|
| 16 | hasClientMiddleware: boolean;
|
| 17 | hasErrorBoundary: boolean;
|
| 18 | imports?: string[];
|
| 19 | css?: string[];
|
| 20 | module: string;
|
| 21 | clientActionModule: string | undefined;
|
| 22 | clientLoaderModule: string | undefined;
|
| 23 | clientMiddlewareModule: string | undefined;
|
| 24 | hydrateFallbackModule: string | undefined;
|
| 25 | parentId?: string;
|
| 26 | }
|
| 27 | declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
|
| 28 | declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, ssr: boolean, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
|
| 29 | declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
|
| 30 |
|
| 31 | type SerializedError = {
|
| 32 | message: string;
|
| 33 | stack?: string;
|
| 34 | };
|
| 35 | interface FrameworkContextObject {
|
| 36 | manifest: AssetsManifest;
|
| 37 | routeModules: RouteModules;
|
| 38 | criticalCss?: CriticalCss;
|
| 39 | serverHandoffString?: string;
|
| 40 | future: FutureConfig;
|
| 41 | ssr: boolean;
|
| 42 | isSpaMode: boolean;
|
| 43 | routeDiscovery: ServerBuild["routeDiscovery"];
|
| 44 | serializeError?(error: Error): SerializedError;
|
| 45 | renderMeta?: {
|
| 46 | didRenderScripts?: boolean;
|
| 47 | streamCache?: Record<number, Promise<void> & {
|
| 48 | result?: {
|
| 49 | done: boolean;
|
| 50 | value: string;
|
| 51 | };
|
| 52 | error?: unknown;
|
| 53 | }>;
|
| 54 | };
|
| 55 | }
|
| 56 | interface EntryContext extends FrameworkContextObject {
|
| 57 | staticHandlerContext: StaticHandlerContext;
|
| 58 | serverHandoffStream?: ReadableStream<Uint8Array>;
|
| 59 | }
|
| 60 | interface FutureConfig {
|
| 61 | unstable_subResourceIntegrity: boolean;
|
| 62 | unstable_trailingSlashAwareDataRequests: boolean;
|
| 63 | v8_middleware: boolean;
|
| 64 | }
|
| 65 | type CriticalCss = string | {
|
| 66 | rel: "stylesheet";
|
| 67 | href: string;
|
| 68 | };
|
| 69 | interface AssetsManifest {
|
| 70 | entry: {
|
| 71 | imports: string[];
|
| 72 | module: string;
|
| 73 | };
|
| 74 | routes: RouteManifest<EntryRoute>;
|
| 75 | url: string;
|
| 76 | version: string;
|
| 77 | hmr?: {
|
| 78 | timestamp?: number;
|
| 79 | runtime: string;
|
| 80 | };
|
| 81 | sri?: Record<string, string> | true;
|
| 82 | }
|
| 83 |
|
| 84 | type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
|
| 85 | interface ServerRoute extends Route {
|
| 86 | children: ServerRoute[];
|
| 87 | module: ServerRouteModule;
|
| 88 | }
|
| 89 |
|
| 90 | type OptionalCriticalCss = CriticalCss | undefined;
|
| 91 | /**
|
| 92 | * The output of the compiler for the server build.
|
| 93 | */
|
| 94 | interface ServerBuild {
|
| 95 | entry: {
|
| 96 | module: ServerEntryModule;
|
| 97 | };
|
| 98 | routes: ServerRouteManifest;
|
| 99 | assets: AssetsManifest;
|
| 100 | basename?: string;
|
| 101 | publicPath: string;
|
| 102 | assetsBuildDirectory: string;
|
| 103 | future: FutureConfig;
|
| 104 | ssr: boolean;
|
| 105 | unstable_getCriticalCss?: (args: {
|
| 106 | pathname: string;
|
| 107 | }) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
|
| 108 | |
| 109 | |
| 110 |
|
| 111 | isSpaMode: boolean;
|
| 112 | prerender: string[];
|
| 113 | routeDiscovery: {
|
| 114 | mode: "lazy" | "initial";
|
| 115 | manifestPath: string;
|
| 116 | };
|
| 117 | allowedActionOrigins?: string[] | false;
|
| 118 | }
|
| 119 | interface HandleDocumentRequestFunction {
|
| 120 | (request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? RouterContextProvider : AppLoadContext): Promise<Response> | Response;
|
| 121 | }
|
| 122 | interface HandleDataRequestFunction {
|
| 123 | (response: Response, args: {
|
| 124 | request: LoaderFunctionArgs["request"] | ActionFunctionArgs["request"];
|
| 125 | context: LoaderFunctionArgs["context"] | ActionFunctionArgs["context"];
|
| 126 | params: LoaderFunctionArgs["params"] | ActionFunctionArgs["params"];
|
| 127 | }): Promise<Response> | Response;
|
| 128 | }
|
| 129 | interface HandleErrorFunction {
|
| 130 | (error: unknown, args: {
|
| 131 | request: LoaderFunctionArgs["request"] | ActionFunctionArgs["request"];
|
| 132 | context: LoaderFunctionArgs["context"] | ActionFunctionArgs["context"];
|
| 133 | params: LoaderFunctionArgs["params"] | ActionFunctionArgs["params"];
|
| 134 | }): void;
|
| 135 | }
|
| 136 | |
| 137 | |
| 138 | |
| 139 |
|
| 140 | interface ServerEntryModule {
|
| 141 | default: HandleDocumentRequestFunction;
|
| 142 | handleDataRequest?: HandleDataRequestFunction;
|
| 143 | handleError?: HandleErrorFunction;
|
| 144 | unstable_instrumentations?: unstable_ServerInstrumentation[];
|
| 145 | streamTimeout?: number;
|
| 146 | }
|
| 147 |
|
| 148 | type ParamKeyValuePair = [string, string];
|
| 149 | type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
|
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 |
|
| 176 | declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
|
| 177 | type JsonObject = {
|
| 178 | [Key in string]: JsonValue;
|
| 179 | } & {
|
| 180 | [Key in string]?: JsonValue | undefined;
|
| 181 | };
|
| 182 | type JsonArray = JsonValue[] | readonly JsonValue[];
|
| 183 | type JsonPrimitive = string | number | boolean | null;
|
| 184 | type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
| 185 | type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
|
| 186 | |
| 187 | |
| 188 |
|
| 189 | interface SharedSubmitOptions {
|
| 190 | |
| 191 | |
| 192 | |
| 193 |
|
| 194 | method?: HTMLFormMethod;
|
| 195 | |
| 196 | |
| 197 | |
| 198 |
|
| 199 | action?: string;
|
| 200 | |
| 201 | |
| 202 | |
| 203 |
|
| 204 | encType?: FormEncType;
|
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 |
|
| 210 | relative?: RelativeRoutingType;
|
| 211 | |
| 212 | |
| 213 | |
| 214 |
|
| 215 | preventScrollReset?: boolean;
|
| 216 | |
| 217 | |
| 218 |
|
| 219 | flushSync?: boolean;
|
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 |
|
| 231 | unstable_defaultShouldRevalidate?: boolean;
|
| 232 | }
|
| 233 | |
| 234 | |
| 235 |
|
| 236 | interface FetcherSubmitOptions extends SharedSubmitOptions {
|
| 237 | }
|
| 238 | |
| 239 | |
| 240 |
|
| 241 | interface SubmitOptions extends FetcherSubmitOptions {
|
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 |
|
| 247 | replace?: boolean;
|
| 248 | |
| 249 | |
| 250 |
|
| 251 | state?: any;
|
| 252 | |
| 253 | |
| 254 |
|
| 255 | fetcherKey?: string;
|
| 256 | |
| 257 | |
| 258 |
|
| 259 | navigate?: boolean;
|
| 260 | |
| 261 | |
| 262 |
|
| 263 | viewTransition?: boolean;
|
| 264 | }
|
| 265 |
|
| 266 | declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
|
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 |
|
| 274 | type DiscoverBehavior = "render" | "none";
|
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 |
|
| 283 | type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
|
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 |
|
| 289 | interface LinksProps {
|
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 |
|
| 295 | nonce?: string | undefined;
|
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 |
|
| 301 | crossOrigin?: "anonymous" | "use-credentials";
|
| 302 | }
|
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 |
|
| 332 | declare function Links({ nonce, crossOrigin }: LinksProps): React.JSX.Element;
|
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 |
|
| 360 | declare function PrefetchPageLinks({ page, ...linkProps }: PageLinkDescriptor): React.JSX.Element | null;
|
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 |
|
| 386 | declare function Meta(): React.JSX.Element;
|
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 |
|
| 406 | type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "async" | "children" | "dangerouslySetInnerHTML" | "defer" | "noModule" | "src" | "suppressHydrationWarning" | "type"> & {
|
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 |
|
| 412 | nonce?: string | undefined;
|
| 413 | };
|
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 |
|
| 447 | declare function Scripts(scriptProps: ScriptsProps): React.JSX.Element | null;
|
| 448 |
|
| 449 | |
| 450 | |
| 451 |
|
| 452 | interface DOMRouterOpts {
|
| 453 | |
| 454 | |
| 455 |
|
| 456 | basename?: string;
|
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 |
|
| 481 | getContext?: RouterInit["getContext"];
|
| 482 | |
| 483 | |
| 484 |
|
| 485 | future?: Partial<FutureConfig$1>;
|
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 |
|
| 554 | hydrationData?: HydrationState;
|
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 |
|
| 603 | unstable_instrumentations?: unstable_ClientInstrumentation[];
|
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 |
|
| 632 | dataStrategy?: DataStrategyFunction;
|
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | |
| 741 | |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | |
| 844 | |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | |
| 864 | |
| 865 | |
| 866 | |
| 867 | |
| 868 | |
| 869 | |
| 870 | |
| 871 | |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 | |
| 891 | |
| 892 | |
| 893 | |
| 894 | |
| 895 | |
| 896 | |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 904 | |
| 905 | |
| 906 | |
| 907 | |
| 908 | |
| 909 | |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | |
| 917 | |
| 918 | |
| 919 | |
| 920 | |
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | |
| 927 | |
| 928 | |
| 929 |
|
| 930 | patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
| 931 | |
| 932 | |
| 933 | |
| 934 |
|
| 935 | window?: Window;
|
| 936 | }
|
| 937 | |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | |
| 954 | |
| 955 | |
| 956 |
|
| 957 | declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
|
| 958 | |
| 959 | |
| 960 | |
| 961 | |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | |
| 976 |
|
| 977 | declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): Router;
|
| 978 | |
| 979 | |
| 980 |
|
| 981 | interface BrowserRouterProps {
|
| 982 | |
| 983 | |
| 984 |
|
| 985 | basename?: string;
|
| 986 | |
| 987 | |
| 988 |
|
| 989 | children?: React.ReactNode;
|
| 990 | |
| 991 | |
| 992 | |
| 993 | |
| 994 | |
| 995 | |
| 996 | |
| 997 | |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 |
|
| 1004 | unstable_useTransitions?: boolean;
|
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 |
|
| 1009 | window?: Window;
|
| 1010 | }
|
| 1011 | |
| 1012 | |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | |
| 1017 | |
| 1018 | |
| 1019 | |
| 1020 | |
| 1021 | |
| 1022 | |
| 1023 | |
| 1024 | |
| 1025 |
|
| 1026 | declare function BrowserRouter({ basename, children, unstable_useTransitions, window, }: BrowserRouterProps): React.JSX.Element;
|
| 1027 | |
| 1028 | |
| 1029 |
|
| 1030 | interface HashRouterProps {
|
| 1031 | |
| 1032 | |
| 1033 |
|
| 1034 | basename?: string;
|
| 1035 | |
| 1036 | |
| 1037 |
|
| 1038 | children?: React.ReactNode;
|
| 1039 | |
| 1040 | |
| 1041 | |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 |
|
| 1053 | unstable_useTransitions?: boolean;
|
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 |
|
| 1058 | window?: Window;
|
| 1059 | }
|
| 1060 | |
| 1061 | |
| 1062 | |
| 1063 | |
| 1064 | |
| 1065 | |
| 1066 | |
| 1067 | |
| 1068 | |
| 1069 | |
| 1070 | |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 |
|
| 1076 | declare function HashRouter({ basename, children, unstable_useTransitions, window, }: HashRouterProps): React.JSX.Element;
|
| 1077 | |
| 1078 | |
| 1079 |
|
| 1080 | interface HistoryRouterProps {
|
| 1081 | |
| 1082 | |
| 1083 |
|
| 1084 | basename?: string;
|
| 1085 | |
| 1086 | |
| 1087 |
|
| 1088 | children?: React.ReactNode;
|
| 1089 | |
| 1090 | |
| 1091 |
|
| 1092 | history: History;
|
| 1093 | |
| 1094 | |
| 1095 | |
| 1096 | |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 |
|
| 1107 | unstable_useTransitions?: boolean;
|
| 1108 | }
|
| 1109 | |
| 1110 | |
| 1111 | |
| 1112 | |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | |
| 1127 |
|
| 1128 | declare function HistoryRouter({ basename, children, history, unstable_useTransitions, }: HistoryRouterProps): React.JSX.Element;
|
| 1129 | declare namespace HistoryRouter {
|
| 1130 | var displayName: string;
|
| 1131 | }
|
| 1132 | |
| 1133 | |
| 1134 |
|
| 1135 | interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | |
| 1146 | |
| 1147 |
|
| 1148 | discover?: DiscoverBehavior;
|
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | |
| 1153 | |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | |
| 1171 | |
| 1172 | |
| 1173 | |
| 1174 | |
| 1175 | |
| 1176 | |
| 1177 |
|
| 1178 | prefetch?: PrefetchBehavior;
|
| 1179 | |
| 1180 | |
| 1181 | |
| 1182 | |
| 1183 | |
| 1184 | |
| 1185 | |
| 1186 | |
| 1187 |
|
| 1188 | reloadDocument?: boolean;
|
| 1189 | |
| 1190 | |
| 1191 | |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | |
| 1207 |
|
| 1208 | replace?: boolean;
|
| 1209 | |
| 1210 | |
| 1211 | |
| 1212 | |
| 1213 | |
| 1214 | |
| 1215 | |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | |
| 1220 | |
| 1221 | |
| 1222 | |
| 1223 | |
| 1224 | |
| 1225 | |
| 1226 | |
| 1227 |
|
| 1228 | state?: any;
|
| 1229 | |
| 1230 | |
| 1231 | |
| 1232 | |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | |
| 1238 |
|
| 1239 | preventScrollReset?: boolean;
|
| 1240 | |
| 1241 | |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | |
| 1249 | |
| 1250 | |
| 1251 | |
| 1252 | |
| 1253 | |
| 1254 | |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | |
| 1259 | |
| 1260 |
|
| 1261 | relative?: RelativeRoutingType;
|
| 1262 | |
| 1263 | |
| 1264 | |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | |
| 1269 | |
| 1270 | |
| 1271 | |
| 1272 | |
| 1273 | |
| 1274 | |
| 1275 | |
| 1276 |
|
| 1277 | to: To;
|
| 1278 | |
| 1279 | |
| 1280 | |
| 1281 | |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | |
| 1289 |
|
| 1290 | viewTransition?: boolean;
|
| 1291 | |
| 1292 | |
| 1293 | |
| 1294 | |
| 1295 | |
| 1296 | |
| 1297 | |
| 1298 | |
| 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | |
| 1305 |
|
| 1306 | unstable_defaultShouldRevalidate?: boolean;
|
| 1307 | |
| 1308 | |
| 1309 | |
| 1310 | |
| 1311 | |
| 1312 | |
| 1313 | |
| 1314 | |
| 1315 | |
| 1316 | |
| 1317 | |
| 1318 | |
| 1319 | |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | |
| 1325 | |
| 1326 | |
| 1327 | |
| 1328 | |
| 1329 | |
| 1330 | |
| 1331 | |
| 1332 | |
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 | |
| 1337 | |
| 1338 | |
| 1339 | |
| 1340 | |
| 1341 | |
| 1342 | |
| 1343 | |
| 1344 | |
| 1345 | |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | |
| 1351 | |
| 1352 | |
| 1353 |
|
| 1354 | unstable_mask?: To;
|
| 1355 | }
|
| 1356 | |
| 1357 | |
| 1358 | |
| 1359 | |
| 1360 | |
| 1361 | |
| 1362 | |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | |
| 1367 | |
| 1368 | |
| 1369 | |
| 1370 | |
| 1371 | |
| 1372 | |
| 1373 | |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | |
| 1378 | |
| 1379 | |
| 1380 | |
| 1381 | |
| 1382 | |
| 1383 | |
| 1384 | |
| 1385 | |
| 1386 |
|
| 1387 | declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
| 1388 | |
| 1389 | |
| 1390 | |
| 1391 | |
| 1392 | |
| 1393 | |
| 1394 | |
| 1395 | |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | |
| 1400 | |
| 1401 | |
| 1402 | |
| 1403 | |
| 1404 | |
| 1405 | |
| 1406 | |
| 1407 | |
| 1408 | |
| 1409 | |
| 1410 | |
| 1411 | |
| 1412 | |
| 1413 | |
| 1414 | |
| 1415 | |
| 1416 | |
| 1417 | |
| 1418 | |
| 1419 | |
| 1420 | |
| 1421 | |
| 1422 |
|
| 1423 | type NavLinkRenderProps = {
|
| 1424 | |
| 1425 | |
| 1426 |
|
| 1427 | isActive: boolean;
|
| 1428 | |
| 1429 | |
| 1430 | |
| 1431 |
|
| 1432 | isPending: boolean;
|
| 1433 | |
| 1434 | |
| 1435 | |
| 1436 |
|
| 1437 | isTransitioning: boolean;
|
| 1438 | };
|
| 1439 | |
| 1440 | |
| 1441 |
|
| 1442 | interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
|
| 1443 | |
| 1444 | |
| 1445 | |
| 1446 | |
| 1447 | |
| 1448 | |
| 1449 | |
| 1450 | |
| 1451 | |
| 1452 | |
| 1453 | |
| 1454 |
|
| 1455 | children?: React.ReactNode | ((props: NavLinkRenderProps) => React.ReactNode);
|
| 1456 | /**
|
| 1457 | * Changes the matching logic to make it case-sensitive:
|
| 1458 | *
|
| 1459 | * | Link | URL | isActive |
|
| 1460 | * | -------------------------------------------- | ------------- | -------- |
|
| 1461 | * | `<NavLink to="/SpOnGe-bOB" />` | `/sponge-bob` | true |
|
| 1462 | * | `<NavLink to="/SpOnGe-bOB" caseSensitive />` | `/sponge-bob` | false |
|
| 1463 | */
|
| 1464 | caseSensitive?: boolean;
|
| 1465 | /**
|
| 1466 | * Classes are automatically applied to `NavLink` that correspond to the state.
|
| 1467 | *
|
| 1468 | * ```css
|
| 1469 | * a.active {
|
| 1470 | * color: red;
|
| 1471 | * }
|
| 1472 | * a.pending {
|
| 1473 | * color: blue;
|
| 1474 | * }
|
| 1475 | * a.transitioning {
|
| 1476 | * view-transition-name: my-transition;
|
| 1477 | * }
|
| 1478 | * ```
|
| 1479 | *
|
| 1480 | * Or you can specify a function that receives {@link NavLinkRenderProps} and
|
| 1481 | * returns the `className`:
|
| 1482 | *
|
| 1483 | * ```tsx
|
| 1484 | * <NavLink className={({ isActive, isPending }) => (
|
| 1485 | * isActive ? "my-active-class" :
|
| 1486 | * isPending ? "my-pending-class" :
|
| 1487 | * ""
|
| 1488 | * )} />
|
| 1489 | * ```
|
| 1490 | */
|
| 1491 | className?: string | ((props: NavLinkRenderProps) => string | undefined);
|
| 1492 | /**
|
| 1493 | * Changes the matching logic for the `active` and `pending` states to only match
|
| 1494 | * to the "end" of the {@link NavLinkProps.to}. If the URL is longer, it will no
|
| 1495 | * longer be considered active.
|
| 1496 | *
|
| 1497 | * | Link | URL | isActive |
|
| 1498 | * | ----------------------------- | ------------ | -------- |
|
| 1499 | * | `<NavLink to="/tasks" />` | `/tasks` | true |
|
| 1500 | * | `<NavLink to="/tasks" />` | `/tasks/123` | true |
|
| 1501 | * | `<NavLink to="/tasks" end />` | `/tasks` | true |
|
| 1502 | * | `<NavLink to="/tasks" end />` | `/tasks/123` | false |
|
| 1503 | *
|
| 1504 | * `<NavLink to="/">` is an exceptional case because _every_ URL matches `/`.
|
| 1505 | * To avoid this matching every single route by default, it effectively ignores
|
| 1506 | * the `end` prop and only matches when you're at the root route.
|
| 1507 | */
|
| 1508 | end?: boolean;
|
| 1509 | /**
|
| 1510 | * Styles can also be applied dynamically via a function that receives
|
| 1511 | * {@link NavLinkRenderProps} and returns the styles:
|
| 1512 | *
|
| 1513 | * ```tsx
|
| 1514 | * <NavLink to="/tasks" style={{ color: "red" }} />
|
| 1515 | * <NavLink to="/tasks" style={({ isActive, isPending }) => ({
|
| 1516 | * color:
|
| 1517 | * isActive ? "red" :
|
| 1518 | * isPending ? "blue" : "black"
|
| 1519 | * })} />
|
| 1520 | * ```
|
| 1521 | */
|
| 1522 | style?: React.CSSProperties | ((props: NavLinkRenderProps) => React.CSSProperties | undefined);
|
| 1523 | }
|
| 1524 | /**
|
| 1525 | * Wraps {@link Link | `<Link>`} with additional props for styling active and
|
| 1526 | * pending states.
|
| 1527 | *
|
| 1528 | * - Automatically applies classes to the link based on its `active` and `pending`
|
| 1529 | * states, see {@link NavLinkProps.className}
|
| 1530 | * - Note that `pending` is only available with Framework and Data modes.
|
| 1531 | * - Automatically applies `aria-current="page"` to the link when the link is active.
|
| 1532 | * See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
| 1533 | * on MDN.
|
| 1534 | * - States are additionally available through the className, style, and children
|
| 1535 | * render props. See {@link NavLinkRenderProps}.
|
| 1536 | *
|
| 1537 | * @example
|
| 1538 | * <NavLink to="/message">Messages</NavLink>
|
| 1539 | *
|
| 1540 | * // Using render props
|
| 1541 | * <NavLink
|
| 1542 | * to="/messages"
|
| 1543 | * className={({ isActive, isPending }) =>
|
| 1544 | * isPending ? "pending" : isActive ? "active" : ""
|
| 1545 | * }
|
| 1546 | * >
|
| 1547 | * Messages
|
| 1548 | * </NavLink>
|
| 1549 | *
|
| 1550 | * @public
|
| 1551 | * @category Components
|
| 1552 | * @param {NavLinkProps.caseSensitive} props.caseSensitive n/a
|
| 1553 | * @param {NavLinkProps.children} props.children n/a
|
| 1554 | * @param {NavLinkProps.className} props.className n/a
|
| 1555 | * @param {NavLinkProps.discover} props.discover [modes: framework] n/a
|
| 1556 | * @param {NavLinkProps.end} props.end n/a
|
| 1557 | * @param {NavLinkProps.prefetch} props.prefetch [modes: framework] n/a
|
| 1558 | * @param {NavLinkProps.preventScrollReset} props.preventScrollReset [modes: framework, data] n/a
|
| 1559 | * @param {NavLinkProps.relative} props.relative n/a
|
| 1560 | * @param {NavLinkProps.reloadDocument} props.reloadDocument n/a
|
| 1561 | * @param {NavLinkProps.replace} props.replace n/a
|
| 1562 | * @param {NavLinkProps.state} props.state n/a
|
| 1563 | * @param {NavLinkProps.style} props.style n/a
|
| 1564 | * @param {NavLinkProps.to} props.to n/a
|
| 1565 | * @param {NavLinkProps.viewTransition} props.viewTransition [modes: framework, data] n/a
|
| 1566 | */
|
| 1567 | declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
| 1568 | /**
|
| 1569 | * Form props shared by navigations and fetchers
|
| 1570 | */
|
| 1571 | interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
| 1572 | /**
|
| 1573 | * The HTTP verb to use when the form is submitted. Supports `"delete"`,
|
| 1574 | * `"get"`, `"patch"`, `"post"`, and `"put"`.
|
| 1575 | *
|
| 1576 | * Native [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
|
| 1577 | * only supports `"get"` and `"post"`, avoid the other verbs if you'd like to
|
| 1578 | * support progressive enhancement
|
| 1579 | */
|
| 1580 | method?: HTMLFormMethod;
|
| 1581 | /**
|
| 1582 | * The encoding type to use for the form submission.
|
| 1583 | *
|
| 1584 | * ```tsx
|
| 1585 | * <Form encType="application/x-www-form-urlencoded"/>
|
| 1586 | * <Form encType="multipart/form-data"/>
|
| 1587 | * <Form encType="text/plain"/>
|
| 1588 | * ```
|
| 1589 | */
|
| 1590 | encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
| 1591 | /**
|
| 1592 | * The URL to submit the form data to. If `undefined`, this defaults to the
|
| 1593 | * closest route in context.
|
| 1594 | */
|
| 1595 | action?: string;
|
| 1596 | /**
|
| 1597 | * Determines whether the form action is relative to the route hierarchy or
|
| 1598 | * the pathname. Use this if you want to opt out of navigating the route
|
| 1599 | * hierarchy and want to instead route based on slash-delimited URL segments.
|
| 1600 | * See {@link RelativeRoutingType}.
|
| 1601 | */
|
| 1602 | relative?: RelativeRoutingType;
|
| 1603 | /**
|
| 1604 | * Prevent the scroll position from resetting to the top of the viewport on
|
| 1605 | * completion of the navigation when using the
|
| 1606 | * {@link ScrollRestoration | `<ScrollRestoration>`} component
|
| 1607 | */
|
| 1608 | preventScrollReset?: boolean;
|
| 1609 | /**
|
| 1610 | * A function to call when the form is submitted. If you call
|
| 1611 | * [`event.preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
|
| 1612 | * then this form will not do anything.
|
| 1613 | */
|
| 1614 | onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
| 1615 | /**
|
| 1616 | * Specify the default revalidation behavior after this submission
|
| 1617 | *
|
| 1618 | * If no `shouldRevalidate` functions are present on the active routes, then this
|
| 1619 | * value will be used directly. Otherwise it will be passed into `shouldRevalidate`
|
| 1620 | * so the route can make the final determination on revalidation. This can be
|
| 1621 | * useful when updating search params and you don't want to trigger a revalidation.
|
| 1622 | *
|
| 1623 | * By default (when not specified), loaders will revalidate according to the routers
|
| 1624 | * standard revalidation behavior.
|
| 1625 | */
|
| 1626 | unstable_defaultShouldRevalidate?: boolean;
|
| 1627 | }
|
| 1628 | /**
|
| 1629 | * Form props available to fetchers
|
| 1630 | * @category Types
|
| 1631 | */
|
| 1632 | interface FetcherFormProps extends SharedFormProps {
|
| 1633 | }
|
| 1634 | /**
|
| 1635 | * Form props available to navigations
|
| 1636 | * @category Types
|
| 1637 | */
|
| 1638 | interface FormProps extends SharedFormProps {
|
| 1639 | /**
|
| 1640 | * Defines the form [lazy route discovery](../../explanation/lazy-route-discovery) behavior.
|
| 1641 | *
|
| 1642 | * - **render** — default, discover the route when the form renders
|
| 1643 | * - **none** — don't eagerly discover, only discover if the form is submitted
|
| 1644 | *
|
| 1645 | * ```tsx
|
| 1646 | * <Form />
|
| 1647 | * <Form discover="render" />
|
| 1648 | * <Form discover="none" />
|
| 1649 | * ```
|
| 1650 | */
|
| 1651 | discover?: DiscoverBehavior;
|
| 1652 | /**
|
| 1653 | * Indicates a specific fetcherKey to use when using `navigate={false}` so you
|
| 1654 | * can pick up the fetcher's state in a different component in a {@link useFetcher}.
|
| 1655 | */
|
| 1656 | fetcherKey?: string;
|
| 1657 | /**
|
| 1658 | * When `false`, skips the navigation and submits via a fetcher internally.
|
| 1659 | * This is essentially a shorthand for {@link useFetcher} + `<fetcher.Form>` where
|
| 1660 | * you don't care about the resulting data in this component.
|
| 1661 | */
|
| 1662 | navigate?: boolean;
|
| 1663 | /**
|
| 1664 | * Forces a full document navigation instead of client side routing and data
|
| 1665 | * fetch.
|
| 1666 | */
|
| 1667 | reloadDocument?: boolean;
|
| 1668 | /**
|
| 1669 | * Replaces the current entry in the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
| 1670 | * stack when the form navigates. Use this if you don't want the user to be
|
| 1671 | * able to click "back" to the page with the form on it.
|
| 1672 | */
|
| 1673 | replace?: boolean;
|
| 1674 | /**
|
| 1675 | * State object to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
| 1676 | * stack entry for this navigation
|
| 1677 | */
|
| 1678 | state?: any;
|
| 1679 | /**
|
| 1680 | * Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
| 1681 | * for this navigation. To apply specific styles during the transition, see
|
| 1682 | * {@link useViewTransitionState}.
|
| 1683 | */
|
| 1684 | viewTransition?: boolean;
|
| 1685 | }
|
| 1686 | /**
|
| 1687 | * A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
|
| 1688 | * that submits data to actions via [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch),
|
| 1689 | * activating pending states in {@link useNavigation} which enables advanced
|
| 1690 | * user interfaces beyond a basic HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
|
| 1691 | * After a form's `action` completes, all data on the page is automatically
|
| 1692 | * revalidated to keep the UI in sync with the data.
|
| 1693 | *
|
| 1694 | * Because it uses the HTML form API, server rendered pages are interactive at a
|
| 1695 | * basic level before JavaScript loads. Instead of React Router managing the
|
| 1696 | * submission, the browser manages the submission as well as the pending states
|
| 1697 | * (like the spinning favicon). After JavaScript loads, React Router takes over
|
| 1698 | * enabling web application user experiences.
|
| 1699 | *
|
| 1700 | * `Form` is most useful for submissions that should also change the URL or
|
| 1701 | * otherwise add an entry to the browser history stack. For forms that shouldn't
|
| 1702 | * manipulate the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
| 1703 | * stack, use {@link FetcherWithComponents.Form | `<fetcher.Form>`}.
|
| 1704 | *
|
| 1705 | * @example
|
| 1706 | * import { Form } from "react-router";
|
| 1707 | *
|
| 1708 | * function NewEvent() {
|
| 1709 | * return (
|
| 1710 | * <Form action="/events" method="post">
|
| 1711 | * <input name="title" type="text" />
|
| 1712 | * <input name="description" type="text" />
|
| 1713 | * </Form>
|
| 1714 | * );
|
| 1715 | * }
|
| 1716 | *
|
| 1717 | * @public
|
| 1718 | * @category Components
|
| 1719 | * @mode framework
|
| 1720 | * @mode data
|
| 1721 | * @param {FormProps.action} action n/a
|
| 1722 | * @param {FormProps.discover} discover n/a
|
| 1723 | * @param {FormProps.encType} encType n/a
|
| 1724 | * @param {FormProps.fetcherKey} fetcherKey n/a
|
| 1725 | * @param {FormProps.method} method n/a
|
| 1726 | * @param {FormProps.navigate} navigate n/a
|
| 1727 | * @param {FormProps.onSubmit} onSubmit n/a
|
| 1728 | * @param {FormProps.preventScrollReset} preventScrollReset n/a
|
| 1729 | * @param {FormProps.relative} relative n/a
|
| 1730 | * @param {FormProps.reloadDocument} reloadDocument n/a
|
| 1731 | * @param {FormProps.replace} replace n/a
|
| 1732 | * @param {FormProps.state} state n/a
|
| 1733 | * @param {FormProps.viewTransition} viewTransition n/a
|
| 1734 | * @param {FormProps.unstable_defaultShouldRevalidate} unstable_defaultShouldRevalidate n/a
|
| 1735 | * @returns A progressively enhanced [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) component
|
| 1736 | */
|
| 1737 | declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
|
| 1738 | type ScrollRestorationProps = ScriptsProps & {
|
| 1739 | /**
|
| 1740 | * A function that returns a key to use for scroll restoration. This is useful
|
| 1741 | * for custom scroll restoration logic, such as using only the pathname so
|
| 1742 | * that later navigations to prior paths will restore the scroll. Defaults to
|
| 1743 | * `location.key`. See {@link GetScrollRestorationKeyFunction}.
|
| 1744 | *
|
| 1745 | * ```tsx
|
| 1746 | * <ScrollRestoration
|
| 1747 | * getKey={(location, matches) => {
|
| 1748 | *
|
| 1749 | * return location.key
|
| 1750 | *
|
| 1751 | *
|
| 1752 | * return location.pathname
|
| 1753 | * }}
|
| 1754 | * />
|
| 1755 | * ```
|
| 1756 | */
|
| 1757 | getKey?: GetScrollRestorationKeyFunction;
|
| 1758 | /**
|
| 1759 | * The key to use for storing scroll positions in [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).
|
| 1760 | * Defaults to `"react-router-scroll-positions"`.
|
| 1761 | */
|
| 1762 | storageKey?: string;
|
| 1763 | };
|
| 1764 | /**
|
| 1765 | * Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the {@link Scripts} component.
|
| 1766 | *
|
| 1767 | * ```tsx
|
| 1768 | * import { ScrollRestoration } from "react-router";
|
| 1769 | *
|
| 1770 | * export default function Root() {
|
| 1771 | * return (
|
| 1772 | * <html>
|
| 1773 | * <body>
|
| 1774 | * <ScrollRestoration />
|
| 1775 | * <Scripts />
|
| 1776 | * </body>
|
| 1777 | * </html>
|
| 1778 | * );
|
| 1779 | * }
|
| 1780 | * ```
|
| 1781 | *
|
| 1782 | * 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.
|
| 1783 | *
|
| 1784 | * ```tsx
|
| 1785 | * <ScrollRestoration nonce={cspNonce} />
|
| 1786 | * ```
|
| 1787 | *
|
| 1788 | * @public
|
| 1789 | * @category Components
|
| 1790 | * @mode framework
|
| 1791 | * @mode data
|
| 1792 | * @param props Props
|
| 1793 | * @param {ScrollRestorationProps.getKey} props.getKey n/a
|
| 1794 | * @param {ScriptsProps.nonce} props.nonce n/a
|
| 1795 | * @param {ScrollRestorationProps.storageKey} props.storageKey n/a
|
| 1796 | * @returns A [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
| 1797 | * tag that restores scroll positions on navigation.
|
| 1798 | */
|
| 1799 | declare function ScrollRestoration({ getKey, storageKey, ...props }: ScrollRestorationProps): React.JSX.Element | null;
|
| 1800 | declare namespace ScrollRestoration {
|
| 1801 | var displayName: string;
|
| 1802 | }
|
| 1803 | /**
|
| 1804 | * Handles the click behavior for router {@link Link | `<Link>`} components.This
|
| 1805 | * is useful if you need to create custom {@link Link | `<Link>`} components with
|
| 1806 | * the same click behavior we use in our exported {@link Link | `<Link>`}.
|
| 1807 | *
|
| 1808 | * @public
|
| 1809 | * @category Hooks
|
| 1810 | * @param to The URL to navigate to, can be a string or a partial {@link Path}.
|
| 1811 | * @param options Options
|
| 1812 | * @param options.preventScrollReset Whether to prevent the scroll position from
|
| 1813 | * being reset to the top of the viewport on completion of the navigation when
|
| 1814 | * using the {@link ScrollRestoration} component. Defaults to `false`.
|
| 1815 | * @param options.relative The {@link RelativeRoutingType | relative routing type}
|
| 1816 | * to use for the link. Defaults to `"route"`.
|
| 1817 | * @param options.replace Whether to replace the current [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
| 1818 | * entry instead of pushing a new one. Defaults to `false`.
|
| 1819 | * @param options.state The state to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
| 1820 | * entry for this navigation. Defaults to `undefined`.
|
| 1821 | * @param options.target The target attribute for the link. Defaults to `undefined`.
|
| 1822 | * @param options.viewTransition Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
| 1823 | * for this navigation. To apply specific styles during the transition, see
|
| 1824 | * {@link useViewTransitionState}. Defaults to `false`.
|
| 1825 | * @param options.unstable_defaultShouldRevalidate Specify the default revalidation
|
| 1826 | * behavior for the navigation. Defaults to `true`.
|
| 1827 | * @param options.unstable_mask Masked location to display in the browser instead
|
| 1828 | * of the router location. Defaults to `undefined`.
|
| 1829 | * @param options.unstable_useTransitions Wraps the navigation in
|
| 1830 | * [`React.startTransition`](https://react.dev/reference/react/startTransition)
|
| 1831 | * for concurrent rendering. Defaults to `false`.
|
| 1832 | * @returns A click handler function that can be used in a custom {@link Link} component.
|
| 1833 | */
|
| 1834 | declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, unstable_mask, state, preventScrollReset, relative, viewTransition, unstable_defaultShouldRevalidate, unstable_useTransitions, }?: {
|
| 1835 | target?: React.HTMLAttributeAnchorTarget;
|
| 1836 | replace?: boolean;
|
| 1837 | unstable_mask?: To;
|
| 1838 | state?: any;
|
| 1839 | preventScrollReset?: boolean;
|
| 1840 | relative?: RelativeRoutingType;
|
| 1841 | viewTransition?: boolean;
|
| 1842 | unstable_defaultShouldRevalidate?: boolean;
|
| 1843 | unstable_useTransitions?: boolean;
|
| 1844 | }): (event: React.MouseEvent<E, MouseEvent>) => void;
|
| 1845 | /**
|
| 1846 | * Returns a tuple of the current URL's [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
|
| 1847 | * and a function to update them. Setting the search params causes a navigation.
|
| 1848 | *
|
| 1849 | * ```tsx
|
| 1850 | * import { useSearchParams } from "react-router";
|
| 1851 | *
|
| 1852 | * export function SomeComponent() {
|
| 1853 | * const [searchParams, setSearchParams] = useSearchParams();
|
| 1854 | *
|
| 1855 | * }
|
| 1856 | * ```
|
| 1857 | *
|
| 1858 | * ### `setSearchParams` function
|
| 1859 | *
|
| 1860 | * The second element of the tuple is a function that can be used to update the
|
| 1861 | * search params. It accepts the same types as `defaultInit` and will cause a
|
| 1862 | * navigation to the new URL.
|
| 1863 | *
|
| 1864 | * ```tsx
|
| 1865 | * let [searchParams, setSearchParams] = useSearchParams();
|
| 1866 | *
|
| 1867 | *
|
| 1868 | * setSearchParams("?tab=1");
|
| 1869 | *
|
| 1870 | *
|
| 1871 | * setSearchParams({ tab: "1" });
|
| 1872 | *
|
| 1873 | *
|
| 1874 | * setSearchParams({ brand: ["nike", "reebok"] });
|
| 1875 | *
|
| 1876 | *
|
| 1877 | * setSearchParams([["tab", "1"]]);
|
| 1878 | *
|
| 1879 | *
|
| 1880 | * setSearchParams(new URLSearchParams("?tab=1"));
|
| 1881 | * ```
|
| 1882 | *
|
| 1883 | * It also supports a function callback like React's
|
| 1884 | * [`setState`](https://react.dev/reference/react/useState#setstate):
|
| 1885 | *
|
| 1886 | * ```tsx
|
| 1887 | * setSearchParams((searchParams) => {
|
| 1888 | * searchParams.set("tab", "2");
|
| 1889 | * return searchParams;
|
| 1890 | * });
|
| 1891 | * ```
|
| 1892 | *
|
| 1893 | * <docs-warning>The function callback version of `setSearchParams` does not support
|
| 1894 | * the [queueing](https://react.dev/reference/react/useState#setstate-parameters)
|
| 1895 | * logic that React's `setState` implements. Multiple calls to `setSearchParams`
|
| 1896 | * in the same tick will not build on the prior value. If you need this behavior,
|
| 1897 | * you can use `setState` manually.</docs-warning>
|
| 1898 | *
|
| 1899 | * ### Notes
|
| 1900 | *
|
| 1901 | * Note that `searchParams` is a stable reference, so you can reliably use it
|
| 1902 | * as a dependency in React's [`useEffect`](https://react.dev/reference/react/useEffect)
|
| 1903 | * hooks.
|
| 1904 | *
|
| 1905 | * ```tsx
|
| 1906 | * useEffect(() => {
|
| 1907 | * console.log(searchParams.get("tab"));
|
| 1908 | * }, [searchParams]);
|
| 1909 | * ```
|
| 1910 | *
|
| 1911 | * However, this also means it's mutable. If you change the object without
|
| 1912 | * calling `setSearchParams`, its values will change between renders if some
|
| 1913 | * other state causes the component to re-render and URL will not reflect the
|
| 1914 | * values.
|
| 1915 | *
|
| 1916 | * @public
|
| 1917 | * @category Hooks
|
| 1918 | * @param defaultInit
|
| 1919 | * You can initialize the search params with a default value, though it **will
|
| 1920 | * not** change the URL on the first render.
|
| 1921 | *
|
| 1922 | * ```tsx
|
| 1923 | *
|
| 1924 | * useSearchParams("?tab=1");
|
| 1925 | *
|
| 1926 | *
|
| 1927 | * useSearchParams({ tab: "1" });
|
| 1928 | *
|
| 1929 | *
|
| 1930 | * useSearchParams({ brand: ["nike", "reebok"] });
|
| 1931 | *
|
| 1932 | *
|
| 1933 | * useSearchParams([["tab", "1"]]);
|
| 1934 | *
|
| 1935 | *
|
| 1936 | * useSearchParams(new URLSearchParams("?tab=1"));
|
| 1937 | * ```
|
| 1938 | * @returns A tuple of the current [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
|
| 1939 | * and a function to update them.
|
| 1940 | */
|
| 1941 | declare function useSearchParams(defaultInit?: URLSearchParamsInit): [URLSearchParams, SetURLSearchParams];
|
| 1942 | /**
|
| 1943 | * Sets new search params and causes a navigation when called.
|
| 1944 | *
|
| 1945 | * ```tsx
|
| 1946 | * <button
|
| 1947 | * onClick={() => {
|
| 1948 | * const params = new URLSearchParams();
|
| 1949 | * params.set("someKey", "someValue");
|
| 1950 | * setSearchParams(params, {
|
| 1951 | * preventScrollReset: true,
|
| 1952 | * });
|
| 1953 | * }}
|
| 1954 | * />
|
| 1955 | * ```
|
| 1956 | *
|
| 1957 | * It also supports a function for setting new search params.
|
| 1958 | *
|
| 1959 | * ```tsx
|
| 1960 | * <button
|
| 1961 | * onClick={() => {
|
| 1962 | * setSearchParams((prev) => {
|
| 1963 | * prev.set("someKey", "someValue");
|
| 1964 | * return prev;
|
| 1965 | * });
|
| 1966 | * }}
|
| 1967 | * />
|
| 1968 | * ```
|
| 1969 | */
|
| 1970 | type SetURLSearchParams = (nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void;
|
| 1971 | /**
|
| 1972 | * Submits a HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
|
| 1973 | * to the server without reloading the page.
|
| 1974 | */
|
| 1975 | interface SubmitFunction {
|
| 1976 | (
|
| 1977 | /**
|
| 1978 | * Can be multiple types of elements and objects
|
| 1979 | *
|
| 1980 | * **[`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)**
|
| 1981 | *
|
| 1982 | * ```tsx
|
| 1983 | * <Form
|
| 1984 | * onSubmit={(event) => {
|
| 1985 | * submit(event.currentTarget);
|
| 1986 | * }}
|
| 1987 | * />
|
| 1988 | * ```
|
| 1989 | *
|
| 1990 | * **[`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
|
| 1991 | *
|
| 1992 | * ```tsx
|
| 1993 | * const formData = new FormData();
|
| 1994 | * formData.append("myKey", "myValue");
|
| 1995 | * submit(formData, { method: "post" });
|
| 1996 | * ```
|
| 1997 | *
|
| 1998 | * **Plain object that will be serialized as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
|
| 1999 | *
|
| 2000 | * ```tsx
|
| 2001 | * submit({ myKey: "myValue" }, { method: "post" });
|
| 2002 | * ```
|
| 2003 | *
|
| 2004 | * **Plain object that will be serialized as JSON**
|
| 2005 | *
|
| 2006 | * ```tsx
|
| 2007 | * submit(
|
| 2008 | * { myKey: "myValue" },
|
| 2009 | * { method: "post", encType: "application/json" }
|
| 2010 | * );
|
| 2011 | * ```
|
| 2012 | */
|
| 2013 | target: SubmitTarget,
|
| 2014 | /**
|
| 2015 | * Options that override the [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)'s
|
| 2016 | * own attributes. Required when submitting arbitrary data without a backing
|
| 2017 | * [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
|
| 2018 | */
|
| 2019 | options?: SubmitOptions): Promise<void>;
|
| 2020 | }
|
| 2021 | /**
|
| 2022 | * Submits a fetcher [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) to the server without reloading the page.
|
| 2023 | */
|
| 2024 | interface FetcherSubmitFunction {
|
| 2025 | (
|
| 2026 | /**
|
| 2027 | * Can be multiple types of elements and objects
|
| 2028 | *
|
| 2029 | * **[`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)**
|
| 2030 | *
|
| 2031 | * ```tsx
|
| 2032 | * <fetcher.Form
|
| 2033 | * onSubmit={(event) => {
|
| 2034 | * fetcher.submit(event.currentTarget);
|
| 2035 | * }}
|
| 2036 | * />
|
| 2037 | * ```
|
| 2038 | *
|
| 2039 | * **[`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
|
| 2040 | *
|
| 2041 | * ```tsx
|
| 2042 | * const formData = new FormData();
|
| 2043 | * formData.append("myKey", "myValue");
|
| 2044 | * fetcher.submit(formData, { method: "post" });
|
| 2045 | * ```
|
| 2046 | *
|
| 2047 | * **Plain object that will be serialized as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)**
|
| 2048 | *
|
| 2049 | * ```tsx
|
| 2050 | * fetcher.submit({ myKey: "myValue" }, { method: "post" });
|
| 2051 | * ```
|
| 2052 | *
|
| 2053 | * **Plain object that will be serialized as JSON**
|
| 2054 | *
|
| 2055 | * ```tsx
|
| 2056 | * fetcher.submit(
|
| 2057 | * { myKey: "myValue" },
|
| 2058 | * { method: "post", encType: "application/json" }
|
| 2059 | * );
|
| 2060 | * ```
|
| 2061 | */
|
| 2062 | target: SubmitTarget, options?: FetcherSubmitOptions): Promise<void>;
|
| 2063 | }
|
| 2064 | /**
|
| 2065 | * The imperative version of {@link Form | `<Form>`} that lets you submit a form
|
| 2066 | * from code instead of a user interaction.
|
| 2067 | *
|
| 2068 | * @example
|
| 2069 | * import { useSubmit } from "react-router";
|
| 2070 | *
|
| 2071 | * function SomeComponent() {
|
| 2072 | * const submit = useSubmit();
|
| 2073 | * return (
|
| 2074 | * <Form onChange={(event) => submit(event.currentTarget)} />
|
| 2075 | * );
|
| 2076 | * }
|
| 2077 | *
|
| 2078 | * @public
|
| 2079 | * @category Hooks
|
| 2080 | * @mode framework
|
| 2081 | * @mode data
|
| 2082 | * @returns A function that can be called to submit a {@link Form} imperatively.
|
| 2083 | */
|
| 2084 | declare function useSubmit(): SubmitFunction;
|
| 2085 | /**
|
| 2086 | * Resolves the URL to the closest route in the component hierarchy instead of
|
| 2087 | * the current URL of the app.
|
| 2088 | *
|
| 2089 | * This is used internally by {@link Form} to resolve the `action` to the closest
|
| 2090 | * route, but can be used generically as well.
|
| 2091 | *
|
| 2092 | * @example
|
| 2093 | * import { useFormAction } from "react-router";
|
| 2094 | *
|
| 2095 | * function SomeComponent() {
|
| 2096 | * // closest route URL
|
| 2097 | * let action = useFormAction();
|
| 2098 | *
|
| 2099 | * // closest route URL + "destroy"
|
| 2100 | * let destroyAction = useFormAction("destroy");
|
| 2101 | * }
|
| 2102 | *
|
| 2103 | * @public
|
| 2104 | * @category Hooks
|
| 2105 | * @mode framework
|
| 2106 | * @mode data
|
| 2107 | * @param action The action to append to the closest route URL. Defaults to the
|
| 2108 | * closest route URL.
|
| 2109 | * @param options Options
|
| 2110 | * @param options.relative The relative routing type to use when resolving the
|
| 2111 | * action. Defaults to `"route"`.
|
| 2112 | * @returns The resolved action URL.
|
| 2113 | */
|
| 2114 | declare function useFormAction(action?: string, { relative }?: {
|
| 2115 | relative?: RelativeRoutingType;
|
| 2116 | }): string;
|
| 2117 | /**
|
| 2118 | * The return value {@link useFetcher} that keeps track of the state of a fetcher.
|
| 2119 | *
|
| 2120 | * ```tsx
|
| 2121 | * let fetcher = useFetcher();
|
| 2122 | * ```
|
| 2123 | */
|
| 2124 | type FetcherWithComponents<TData> = Fetcher<TData> & {
|
| 2125 | /**
|
| 2126 | * Just like {@link Form} except it doesn't cause a navigation.
|
| 2127 | *
|
| 2128 | * ```tsx
|
| 2129 | * function SomeComponent() {
|
| 2130 | * const fetcher = useFetcher()
|
| 2131 | * return (
|
| 2132 | * <fetcher.Form method="post" action="/some/route">
|
| 2133 | * <input type="text" />
|
| 2134 | * </fetcher.Form>
|
| 2135 | * )
|
| 2136 | * }
|
| 2137 | * ```
|
| 2138 | */
|
| 2139 | Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
|
| 2140 | /**
|
| 2141 | * Loads data from a route. Useful for loading data imperatively inside user
|
| 2142 | * events outside a normal button or form, like a combobox or search input.
|
| 2143 | *
|
| 2144 | * ```tsx
|
| 2145 | * let fetcher = useFetcher()
|
| 2146 | *
|
| 2147 | * <input onChange={e => {
|
| 2148 | * fetcher.load(`/search?q=${e.target.value}`)
|
| 2149 | * }} />
|
| 2150 | * ```
|
| 2151 | */
|
| 2152 | load: (href: string, opts?: {
|
| 2153 | /**
|
| 2154 | * Wraps the initial state update for this `fetcher.load` in a
|
| 2155 | * [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
|
| 2156 | * call instead of the default [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
| 2157 | * This allows you to perform synchronous DOM actions immediately after the
|
| 2158 | * update is flushed to the DOM.
|
| 2159 | */
|
| 2160 | flushSync?: boolean;
|
| 2161 | }) => Promise<void>;
|
| 2162 | /**
|
| 2163 | * Reset a fetcher back to an empty/idle state.
|
| 2164 | *
|
| 2165 | * If the fetcher is currently in-flight, the
|
| 2166 | * [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
|
| 2167 | * will be aborted with the `reason`, if provided.
|
| 2168 | *
|
| 2169 | * @param reason Optional `reason` to provide to [`AbortController.abort()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort)
|
| 2170 | * @returns void
|
| 2171 | */
|
| 2172 | reset: (opts?: {
|
| 2173 | reason?: unknown;
|
| 2174 | }) => void;
|
| 2175 | /**
|
| 2176 | * Submits form data to a route. While multiple nested routes can match a URL, only the leaf route will be called.
|
| 2177 | *
|
| 2178 | * The `formData` can be multiple types:
|
| 2179 | *
|
| 2180 | * - [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
|
| 2181 | * A `FormData` instance.
|
| 2182 | * - [`HTMLFormElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement)
|
| 2183 | * A [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) DOM element.
|
| 2184 | * - `Object`
|
| 2185 | * An object of key/value-pairs that will be converted to a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
|
| 2186 | * instance by default. You can pass a more complex object and serialize it
|
| 2187 | * as JSON by specifying `encType: "application/json"`. See
|
| 2188 | * {@link useSubmit} for more details.
|
| 2189 | *
|
| 2190 | * If the method is `GET`, then the route [`loader`](../../start/framework/route-module#loader)
|
| 2191 | * is being called and with the `formData` serialized to the url as [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
|
| 2192 | * If `DELETE`, `PATCH`, `POST`, or `PUT`, then the route [`action`](../../start/framework/route-module#action)
|
| 2193 | * is being called with `formData` as the body.
|
| 2194 | *
|
| 2195 | * ```tsx
|
| 2196 | *
|
| 2197 | * const formData = new FormData();
|
| 2198 | * fetcher.submit(formData);
|
| 2199 | *
|
| 2200 | *
|
| 2201 | * fetcher.submit(event.currentTarget.form, {
|
| 2202 | * method: "POST",
|
| 2203 | * });
|
| 2204 | *
|
| 2205 | *
|
| 2206 | * fetcher.submit(
|
| 2207 | * { serialized: "values" },
|
| 2208 | * { method: "POST" }
|
| 2209 | * );
|
| 2210 | *
|
| 2211 | *
|
| 2212 | * fetcher.submit(
|
| 2213 | * {
|
| 2214 | * deeply: {
|
| 2215 | * nested: {
|
| 2216 | * json: "values",
|
| 2217 | * },
|
| 2218 | * },
|
| 2219 | * },
|
| 2220 | * {
|
| 2221 | * method: "POST",
|
| 2222 | * encType: "application/json",
|
| 2223 | * }
|
| 2224 | * );
|
| 2225 | * ```
|
| 2226 | */
|
| 2227 | submit: FetcherSubmitFunction;
|
| 2228 | };
|
| 2229 | /**
|
| 2230 | * Useful for creating complex, dynamic user interfaces that require multiple,
|
| 2231 | * concurrent data interactions without causing a navigation.
|
| 2232 | *
|
| 2233 | * Fetchers track their own, independent state and can be used to load data, submit
|
| 2234 | * forms, and generally interact with [`action`](../../start/framework/route-module#action)
|
| 2235 | * and [`loader`](../../start/framework/route-module#loader) functions.
|
| 2236 | *
|
| 2237 | * @example
|
| 2238 | * import { useFetcher } from "react-router"
|
| 2239 | *
|
| 2240 | * function SomeComponent() {
|
| 2241 | * let fetcher = useFetcher()
|
| 2242 | *
|
| 2243 | * // states are available on the fetcher
|
| 2244 | * fetcher.state // "idle" | "loading" | "submitting"
|
| 2245 | * fetcher.data // the data returned from the action or loader
|
| 2246 | *
|
| 2247 | * // render a form
|
| 2248 | * <fetcher.Form method="post" />
|
| 2249 | *
|
| 2250 | * // load data
|
| 2251 | * fetcher.load("/some/route")
|
| 2252 | *
|
| 2253 | * // submit data
|
| 2254 | * fetcher.submit(someFormRef, { method: "post" })
|
| 2255 | * fetcher.submit(someData, {
|
| 2256 | * method: "post",
|
| 2257 | * encType: "application/json"
|
| 2258 | * })
|
| 2259 | *
|
| 2260 | * // reset fetcher
|
| 2261 | * fetcher.reset()
|
| 2262 | * }
|
| 2263 | *
|
| 2264 | * @public
|
| 2265 | * @category Hooks
|
| 2266 | * @mode framework
|
| 2267 | * @mode data
|
| 2268 | * @param options Options
|
| 2269 | * @param options.key A unique key to identify the fetcher.
|
| 2270 | *
|
| 2271 | *
|
| 2272 | * By default, `useFetcher` generates a unique fetcher scoped to that component.
|
| 2273 | * If you want to identify a fetcher with your own key such that you can access
|
| 2274 | * it from elsewhere in your app, you can do that with the `key` option:
|
| 2275 | *
|
| 2276 | * ```tsx
|
| 2277 | * function SomeComp() {
|
| 2278 | * let fetcher = useFetcher({ key: "my-key" })
|
| 2279 | *
|
| 2280 | * }
|
| 2281 | *
|
| 2282 | *
|
| 2283 | * function AnotherComp() {
|
| 2284 | *
|
| 2285 | * let fetcher = useFetcher({ key: "my-key" });
|
| 2286 | *
|
| 2287 | * }
|
| 2288 | * ```
|
| 2289 | * @returns A {@link FetcherWithComponents} object that contains the fetcher's state, data, and components for submitting forms and loading data.
|
| 2290 | */
|
| 2291 | declare function useFetcher<T = any>({ key, }?: {
|
| 2292 | key?: string;
|
| 2293 | }): FetcherWithComponents<SerializeFrom<T>>;
|
| 2294 | /**
|
| 2295 | * Returns an array of all in-flight {@link Fetcher}s. This is useful for components
|
| 2296 | * throughout the app that didn't create the fetchers but want to use their submissions
|
| 2297 | * to participate in optimistic UI.
|
| 2298 | *
|
| 2299 | * @example
|
| 2300 | * import { useFetchers } from "react-router";
|
| 2301 | *
|
| 2302 | * function SomeComponent() {
|
| 2303 | * const fetchers = useFetchers();
|
| 2304 | * fetchers[0].formData; // FormData
|
| 2305 | * fetchers[0].state; // etc.
|
| 2306 | * // ...
|
| 2307 | * }
|
| 2308 | *
|
| 2309 | * @public
|
| 2310 | * @category Hooks
|
| 2311 | * @mode framework
|
| 2312 | * @mode data
|
| 2313 | * @returns An array of all in-flight {@link Fetcher}s, each with a unique `key`
|
| 2314 | * property.
|
| 2315 | */
|
| 2316 | declare function useFetchers(): (Fetcher & {
|
| 2317 | key: string;
|
| 2318 | })[];
|
| 2319 | /**
|
| 2320 | * When rendered inside a {@link RouterProvider}, will restore scroll positions
|
| 2321 | * on navigations
|
| 2322 | *
|
| 2323 | * <!--
|
| 2324 | * Not marked `@public` because we only export as UNSAFE_ and therefore we don't
|
| 2325 | * maintain an .md file for this hook
|
| 2326 | * -->
|
| 2327 | *
|
| 2328 | * @name UNSAFE_useScrollRestoration
|
| 2329 | * @category Hooks
|
| 2330 | * @mode framework
|
| 2331 | * @mode data
|
| 2332 | * @param options Options
|
| 2333 | * @param options.getKey A function that returns a key to use for scroll restoration.
|
| 2334 | * This is useful for custom scroll restoration logic, such as using only the pathname
|
| 2335 | * so that subsequent navigations to prior paths will restore the scroll. Defaults
|
| 2336 | * to `location.key`.
|
| 2337 | * @param options.storageKey The key to use for storing scroll positions in
|
| 2338 | * `sessionStorage`. Defaults to `"react-router-scroll-positions"`.
|
| 2339 | * @returns {void}
|
| 2340 | */
|
| 2341 | declare function useScrollRestoration({ getKey, storageKey, }?: {
|
| 2342 | getKey?: GetScrollRestorationKeyFunction;
|
| 2343 | storageKey?: string;
|
| 2344 | }): void;
|
| 2345 | /**
|
| 2346 | * Set up a callback to be fired on [Window's `beforeunload` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event).
|
| 2347 | *
|
| 2348 | * @public
|
| 2349 | * @category Hooks
|
| 2350 | * @param callback The callback to be called when the [`beforeunload` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event)
|
| 2351 | * is fired.
|
| 2352 | * @param options Options
|
| 2353 | * @param options.capture If `true`, the event will be captured during the capture
|
| 2354 | * phase. Defaults to `false`.
|
| 2355 | * @returns {void}
|
| 2356 | */
|
| 2357 | declare function useBeforeUnload(callback: (event: BeforeUnloadEvent) => any, options?: {
|
| 2358 | capture?: boolean;
|
| 2359 | }): void;
|
| 2360 | /**
|
| 2361 | * Wrapper around {@link useBlocker} to show a [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm)
|
| 2362 | * prompt to users instead of building a custom UI with {@link useBlocker}.
|
| 2363 | *
|
| 2364 | * The `unstable_` flag will not be removed because this technique has a lot of
|
| 2365 | * rough edges and behaves very differently (and incorrectly sometimes) across
|
| 2366 | * browsers if users click addition back/forward navigations while the
|
| 2367 | * confirmation is open. Use at your own risk.
|
| 2368 | *
|
| 2369 | * @example
|
| 2370 | * function ImportantForm() {
|
| 2371 | * let [value, setValue] = React.useState("");
|
| 2372 | *
|
| 2373 | * // Block navigating elsewhere when data has been entered into the input
|
| 2374 | * unstable_usePrompt({
|
| 2375 | * message: "Are you sure?",
|
| 2376 | * when: ({ currentLocation, nextLocation }) =>
|
| 2377 | * value !== "" &&
|
| 2378 | * currentLocation.pathname !== nextLocation.pathname,
|
| 2379 | * });
|
| 2380 | *
|
| 2381 | * return (
|
| 2382 | * <Form method="post">
|
| 2383 | * <label>
|
| 2384 | * Enter some important data:
|
| 2385 | * <input
|
| 2386 | * name="data"
|
| 2387 | * value={value}
|
| 2388 | * onChange={(e) => setValue(e.target.value)}
|
| 2389 | * />
|
| 2390 | * </label>
|
| 2391 | * <button type="submit">Save</button>
|
| 2392 | * </Form>
|
| 2393 | * );
|
| 2394 | * }
|
| 2395 | *
|
| 2396 | * @name unstable_usePrompt
|
| 2397 | * @public
|
| 2398 | * @category Hooks
|
| 2399 | * @mode framework
|
| 2400 | * @mode data
|
| 2401 | * @param options Options
|
| 2402 | * @param options.message The message to show in the confirmation dialog.
|
| 2403 | * @param options.when A boolean or a function that returns a boolean indicating
|
| 2404 | * whether to block the navigation. If a function is provided, it will receive an
|
| 2405 | * object with `currentLocation` and `nextLocation` properties.
|
| 2406 | * @returns {void}
|
| 2407 | */
|
| 2408 | declare function usePrompt({ when, message, }: {
|
| 2409 | when: boolean | BlockerFunction;
|
| 2410 | message: string;
|
| 2411 | }): void;
|
| 2412 | /**
|
| 2413 | * This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
| 2414 | * to the specified location. This can be used to apply finer-grained styles to
|
| 2415 | * elements to further customize the view transition. This requires that view
|
| 2416 | * transitions have been enabled for the given navigation via {@link LinkProps.viewTransition}
|
| 2417 | * (or the `Form`, `submit`, or `navigate` call)
|
| 2418 | *
|
| 2419 | * @public
|
| 2420 | * @category Hooks
|
| 2421 | * @mode framework
|
| 2422 | * @mode data
|
| 2423 | * @param to The {@link To} location to check for an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API).
|
| 2424 | * @param options Options
|
| 2425 | * @param options.relative The relative routing type to use when resolving the
|
| 2426 | * `to` location, defaults to `"route"`. See {@link RelativeRoutingType} for
|
| 2427 | * more details.
|
| 2428 | * @returns `true` if there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
| 2429 | * to the specified {@link Location}, otherwise `false`.
|
| 2430 | */
|
| 2431 | declare function useViewTransitionState(to: To, { relative }?: {
|
| 2432 | relative?: RelativeRoutingType;
|
| 2433 | }): boolean;
|
| 2434 |
|
| 2435 | /**
|
| 2436 | * @category Types
|
| 2437 | */
|
| 2438 | interface StaticRouterProps {
|
| 2439 | /**
|
| 2440 | * The base URL for the static router (default: `/`)
|
| 2441 | */
|
| 2442 | basename?: string;
|
| 2443 | /**
|
| 2444 | * The child elements to render inside the static router
|
| 2445 | */
|
| 2446 | children?: React.ReactNode;
|
| 2447 | /**
|
| 2448 | * The {@link Location} to render the static router at (default: `/`)
|
| 2449 | */
|
| 2450 | location: Partial<Location> | string;
|
| 2451 | }
|
| 2452 | /**
|
| 2453 | * A {@link Router | `<Router>`} that may not navigate to any other {@link Location}.
|
| 2454 | * This is useful on the server where there is no stateful UI.
|
| 2455 | *
|
| 2456 | * @public
|
| 2457 | * @category Declarative Routers
|
| 2458 | * @mode declarative
|
| 2459 | * @param props Props
|
| 2460 | * @param {StaticRouterProps.basename} props.basename n/a
|
| 2461 | * @param {StaticRouterProps.children} props.children n/a
|
| 2462 | * @param {StaticRouterProps.location} props.location n/a
|
| 2463 | * @returns A React element that renders the static {@link Router | `<Router>`}
|
| 2464 | */
|
| 2465 | declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
|
| 2466 | /**
|
| 2467 | * @category Types
|
| 2468 | */
|
| 2469 | interface StaticRouterProviderProps {
|
| 2470 | /**
|
| 2471 | * The {@link StaticHandlerContext} returned from {@link StaticHandler}'s
|
| 2472 | * `query`
|
| 2473 | */
|
| 2474 | context: StaticHandlerContext;
|
| 2475 | /**
|
| 2476 | * The static {@link DataRouter} from {@link createStaticRouter}
|
| 2477 | */
|
| 2478 | router: Router;
|
| 2479 | /**
|
| 2480 | * Whether to hydrate the router on the client (default `true`)
|
| 2481 | */
|
| 2482 | hydrate?: boolean;
|
| 2483 | /**
|
| 2484 | * The [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
|
| 2485 | * to use for the hydration [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
| 2486 | * tag
|
| 2487 | */
|
| 2488 | nonce?: string;
|
| 2489 | }
|
| 2490 | /**
|
| 2491 | * A {@link DataRouter} that may not navigate to any other {@link Location}.
|
| 2492 | * This is useful on the server where there is no stateful UI.
|
| 2493 | *
|
| 2494 | * @example
|
| 2495 | * export async function handleRequest(request: Request) {
|
| 2496 | * let { query, dataRoutes } = createStaticHandler(routes);
|
| 2497 | * let context = await query(request));
|
| 2498 | *
|
| 2499 | * if (context instanceof Response) {
|
| 2500 | * return context;
|
| 2501 | * }
|
| 2502 | *
|
| 2503 | * let router = createStaticRouter(dataRoutes, context);
|
| 2504 | * return new Response(
|
| 2505 | * ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
| 2506 | * { headers: { "Content-Type": "text/html" } }
|
| 2507 | * );
|
| 2508 | * }
|
| 2509 | *
|
| 2510 | * @public
|
| 2511 | * @category Data Routers
|
| 2512 | * @mode data
|
| 2513 | * @param props Props
|
| 2514 | * @param {StaticRouterProviderProps.context} props.context n/a
|
| 2515 | * @param {StaticRouterProviderProps.hydrate} props.hydrate n/a
|
| 2516 | * @param {StaticRouterProviderProps.nonce} props.nonce n/a
|
| 2517 | * @param {StaticRouterProviderProps.router} props.router n/a
|
| 2518 | * @returns A React element that renders the static router provider
|
| 2519 | */
|
| 2520 | declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
|
| 2521 | type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
|
| 2522 | /**
|
| 2523 | * Create a static handler to perform server-side data loading
|
| 2524 | *
|
| 2525 | * @example
|
| 2526 | * export async function handleRequest(request: Request) {
|
| 2527 | * let { query, dataRoutes } = createStaticHandler(routes);
|
| 2528 | * let context = await query(request);
|
| 2529 | *
|
| 2530 | * if (context instanceof Response) {
|
| 2531 | * return context;
|
| 2532 | * }
|
| 2533 | *
|
| 2534 | * let router = createStaticRouter(dataRoutes, context);
|
| 2535 | * return new Response(
|
| 2536 | * ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
| 2537 | * { headers: { "Content-Type": "text/html" } }
|
| 2538 | * );
|
| 2539 | * }
|
| 2540 | *
|
| 2541 | * @public
|
| 2542 | * @category Data Routers
|
| 2543 | * @mode data
|
| 2544 | * @param routes The {@link RouteObject | route objects} to create a static
|
| 2545 | * handler for
|
| 2546 | * @param opts Options
|
| 2547 | * @param opts.basename The base URL for the static handler (default: `/`)
|
| 2548 | * @param opts.future Future flags for the static handler
|
| 2549 | * @returns A static handler that can be used to query data for the provided
|
| 2550 | * routes
|
| 2551 | */
|
| 2552 | declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
| 2553 | /**
|
| 2554 | * Create a static {@link DataRouter} for server-side rendering
|
| 2555 | *
|
| 2556 | * @example
|
| 2557 | * export async function handleRequest(request: Request) {
|
| 2558 | * let { query, dataRoutes } = createStaticHandler(routes);
|
| 2559 | * let context = await query(request);
|
| 2560 | *
|
| 2561 | * if (context instanceof Response) {
|
| 2562 | * return context;
|
| 2563 | * }
|
| 2564 | *
|
| 2565 | * let router = createStaticRouter(dataRoutes, context);
|
| 2566 | * return new Response(
|
| 2567 | * ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
| 2568 | * { headers: { "Content-Type": "text/html" } }
|
| 2569 | * );
|
| 2570 | * }
|
| 2571 | *
|
| 2572 | * @public
|
| 2573 | * @category Data Routers
|
| 2574 | * @mode data
|
| 2575 | * @param routes The route objects to create a static {@link DataRouter} for
|
| 2576 | * @param context The {@link StaticHandlerContext} returned from {@link StaticHandler}'s
|
| 2577 | * `query`
|
| 2578 | * @param opts Options
|
| 2579 | * @param opts.future Future flags for the static {@link DataRouter}
|
| 2580 | * @returns A static {@link DataRouter} that can be used to render the provided routes
|
| 2581 | */
|
| 2582 | declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
|
| 2583 | future?: Partial<FutureConfig$1>;
|
| 2584 | }): Router;
|
| 2585 |
|
| 2586 | export { type ScriptsProps as $, type AssetsManifest as A, type BrowserRouterProps as B, useViewTransitionState as C, type DOMRouterOpts as D, type EntryContext as E, type FutureConfig as F, type FetcherSubmitOptions as G, type HashRouterProps as H, type SubmitOptions as I, type SubmitTarget as J, createSearchParams as K, type LinkProps as L, type StaticRouterProps as M, type NavLinkProps as N, type StaticRouterProviderProps as O, type ParamKeyValuePair as P, createStaticHandler as Q, createStaticRouter as R, type ServerBuild as S, StaticRouter as T, type URLSearchParamsInit as U, StaticRouterProvider as V, Meta as W, Links as X, Scripts as Y, PrefetchPageLinks as Z, type LinksProps as _, type HistoryRouterProps as a, type PrefetchBehavior as a0, type DiscoverBehavior as a1, type HandleDataRequestFunction as a2, type HandleDocumentRequestFunction as a3, type HandleErrorFunction as a4, type ServerEntryModule as a5, FrameworkContext as a6, createClientRoutes as a7, createClientRoutesWithHMRRevalidationOptOut as a8, shouldHydrateRouteLoader as a9, useScrollRestoration as aa, type NavLinkRenderProps as b, type FetcherFormProps as c, type FormProps as d, type ScrollRestorationProps as e, type SetURLSearchParams as f, type SubmitFunction as g, type FetcherSubmitFunction as h, type FetcherWithComponents as i, createBrowserRouter as j, createHashRouter as k, BrowserRouter as l, HashRouter as m, Link as n, HistoryRouter as o, NavLink as p, Form as q, ScrollRestoration as r, useSearchParams as s, useSubmit as t, useLinkClickHandler as u, useFormAction as v, useFetcher as w, useFetchers as x, useBeforeUnload as y, usePrompt as z };
|
| 2587 | |
| \ | No newline at end of file |