react-router 7.9.6 → 7.10.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -10
- package/dist/development/{browser-BbBXFHbO.d.ts → browser-BpxEZgZC.d.ts} +1 -1
- package/dist/development/{browser-C07r42Tt.d.mts → browser-C5z6FZmz.d.mts} +1 -1
- package/dist/development/{chunk-4WY6JWTD.mjs → chunk-GIMUO62I.mjs} +208 -221
- package/dist/development/{chunk-AMVS5XVJ.js → chunk-KQLPIZ7E.js} +201 -258
- package/dist/development/{chunk-PZWDWJAY.js → chunk-RHWHYDYZ.js} +7 -7
- package/dist/development/{chunk-G3INQAYP.mjs → chunk-V5RTLP6E.mjs} +15 -5
- package/dist/development/{chunk-O4JVZSOY.js → chunk-XHWAND4X.js} +167 -123
- package/dist/development/dom-export.d.mts +29 -10
- package/dist/development/dom-export.d.ts +29 -10
- package/dist/development/dom-export.js +158 -103
- package/dist/development/dom-export.mjs +133 -79
- package/dist/{production/index-react-server-client-Da3kmxNd.d.ts → development/index-react-server-client-CCjKYJTH.d.ts} +75 -180
- package/dist/development/{index-react-server-client-rcoGPJhU.d.mts → index-react-server-client-CipGfVBI.d.mts} +75 -180
- package/dist/development/index-react-server-client.d.mts +2 -2
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +19 -4
- package/dist/development/index-react-server.d.ts +19 -4
- package/dist/development/index-react-server.js +30 -24
- package/dist/development/index-react-server.mjs +30 -24
- package/dist/development/index.d.mts +19 -15
- package/dist/development/index.d.ts +19 -15
- package/dist/development/index.js +92 -82
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-Unc20tLk.d.ts → development/instrumentation-BB0wRuqz.d.ts} +93 -11
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-QkB3HGjm.d.mts → register-C1RwVJAt.d.mts} +1 -1
- package/dist/development/{register-BpU9rFBJ.d.ts → register-ODDAAYlf.d.ts} +1 -1
- package/dist/development/{router-CAvh_Drx.d.mts → router-CwNp5l9u.d.mts} +93 -11
- package/dist/production/{browser-BbBXFHbO.d.ts → browser-BpxEZgZC.d.ts} +1 -1
- package/dist/production/{browser-C07r42Tt.d.mts → browser-C5z6FZmz.d.mts} +1 -1
- package/dist/production/{chunk-QN64DHI4.js → chunk-3MVZKESN.js} +167 -123
- package/dist/production/{chunk-FUSXQSWG.mjs → chunk-7F5XUDXM.mjs} +208 -221
- package/dist/production/{chunk-EAIF67OW.js → chunk-C7S4I3K5.js} +201 -258
- package/dist/production/{chunk-FDUMZGKM.mjs → chunk-ISOIFGFA.mjs} +15 -5
- package/dist/production/{chunk-G5A35OQU.js → chunk-YU3WNS3T.js} +7 -7
- package/dist/production/dom-export.d.mts +29 -10
- package/dist/production/dom-export.d.ts +29 -10
- package/dist/production/dom-export.js +158 -103
- package/dist/production/dom-export.mjs +133 -79
- package/dist/{development/index-react-server-client-Da3kmxNd.d.ts → production/index-react-server-client-CCjKYJTH.d.ts} +75 -180
- package/dist/production/{index-react-server-client-rcoGPJhU.d.mts → index-react-server-client-CipGfVBI.d.mts} +75 -180
- package/dist/production/index-react-server-client.d.mts +2 -2
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +19 -4
- package/dist/production/index-react-server.d.ts +19 -4
- package/dist/production/index-react-server.js +30 -24
- package/dist/production/index-react-server.mjs +30 -24
- package/dist/production/index.d.mts +19 -15
- package/dist/production/index.d.ts +19 -15
- package/dist/production/index.js +92 -82
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-Unc20tLk.d.ts → production/instrumentation-BB0wRuqz.d.ts} +93 -11
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{register-QkB3HGjm.d.mts → register-C1RwVJAt.d.mts} +1 -1
- package/dist/production/{register-BpU9rFBJ.d.ts → register-ODDAAYlf.d.ts} +1 -1
- package/dist/production/{router-CAvh_Drx.d.mts → router-CwNp5l9u.d.mts} +93 -11
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.10.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
isSession,
|
|
29
29
|
routeRSCServerRequest,
|
|
30
30
|
setDevServerHooks
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-ISOIFGFA.mjs";
|
|
32
32
|
import {
|
|
33
33
|
Action,
|
|
34
34
|
Await,
|
|
@@ -139,7 +139,7 @@ import {
|
|
|
139
139
|
withComponentProps,
|
|
140
140
|
withErrorBoundaryProps,
|
|
141
141
|
withHydrateFallbackProps
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-7F5XUDXM.mjs";
|
|
143
143
|
export {
|
|
144
144
|
Await,
|
|
145
145
|
BrowserRouter,
|
package/dist/{development/instrumentation-Unc20tLk.d.ts → production/instrumentation-BB0wRuqz.d.ts}
RENAMED
|
@@ -541,6 +541,8 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
|
|
|
541
541
|
route: Promise<void> | undefined;
|
|
542
542
|
};
|
|
543
543
|
/**
|
|
544
|
+
* @deprecated Deprecated in favor of `shouldCallHandler`
|
|
545
|
+
*
|
|
544
546
|
* A boolean value indicating whether this route handler should be called in
|
|
545
547
|
* this pass.
|
|
546
548
|
*
|
|
@@ -566,8 +568,20 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
|
|
|
566
568
|
* custom `shouldRevalidate` implementations)
|
|
567
569
|
*/
|
|
568
570
|
shouldLoad: boolean;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
+
/**
|
|
572
|
+
* Arguments passed to the `shouldRevalidate` function for this `loader` execution.
|
|
573
|
+
* Will be `null` if this is not a revalidating loader {@link DataStrategyMatch}.
|
|
574
|
+
*/
|
|
575
|
+
shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
|
|
576
|
+
/**
|
|
577
|
+
* Determine if this route's handler should be called during this `dataStrategy`
|
|
578
|
+
* execution. Calling it with no arguments will leverage the default revalidation
|
|
579
|
+
* behavior. You can pass your own `defaultShouldRevalidate` value if you wish
|
|
580
|
+
* to change the default revalidation behavior with your `dataStrategy`.
|
|
581
|
+
*
|
|
582
|
+
* @param defaultShouldRevalidate `defaultShouldRevalidate` override value (optional)
|
|
583
|
+
*/
|
|
584
|
+
shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
|
|
571
585
|
/**
|
|
572
586
|
* An async function that will resolve any `route.lazy` implementations and
|
|
573
587
|
* execute the route's handler (if necessary), returning a {@link DataStrategyResult}
|
|
@@ -1015,7 +1029,8 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
1015
1029
|
/**
|
|
1016
1030
|
* Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
|
|
1017
1031
|
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1018
|
-
* thrown from an [`action`](../../start/framework/route-module#action)
|
|
1032
|
+
* thrown from an [`action`](../../start/framework/route-module#action) or
|
|
1033
|
+
* [`loader`](../../start/framework/route-module#loader) function.
|
|
1019
1034
|
*
|
|
1020
1035
|
* @example
|
|
1021
1036
|
* import { isRouteErrorResponse } from "react-router";
|
|
@@ -1041,7 +1056,6 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
1041
1056
|
* @mode data
|
|
1042
1057
|
* @param error The error to check.
|
|
1043
1058
|
* @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
|
|
1044
|
-
*
|
|
1045
1059
|
*/
|
|
1046
1060
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
1047
1061
|
|
|
@@ -1395,6 +1409,7 @@ type ViewTransitionOpts = {
|
|
|
1395
1409
|
interface RouterSubscriber {
|
|
1396
1410
|
(state: RouterState, opts: {
|
|
1397
1411
|
deletedFetchers: string[];
|
|
1412
|
+
newErrors: RouteData | null;
|
|
1398
1413
|
viewTransitionOpts?: ViewTransitionOpts;
|
|
1399
1414
|
flushSync: boolean;
|
|
1400
1415
|
}): void;
|
|
@@ -1660,7 +1675,7 @@ interface MemoryRouterOpts {
|
|
|
1660
1675
|
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
1661
1676
|
* mostly useful for observability such as wrapping navigations, fetches,
|
|
1662
1677
|
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
1663
|
-
* tracing.
|
|
1678
|
+
* tracing. See the [docs](../../how-to/instrumentation) for more information.
|
|
1664
1679
|
*
|
|
1665
1680
|
* ```tsx
|
|
1666
1681
|
* let router = createBrowserRouter(routes, {
|
|
@@ -1704,8 +1719,32 @@ interface MemoryRouterOpts {
|
|
|
1704
1719
|
*/
|
|
1705
1720
|
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
1706
1721
|
/**
|
|
1707
|
-
* Override the default data strategy of
|
|
1708
|
-
*
|
|
1722
|
+
* Override the default data strategy of running loaders in parallel -
|
|
1723
|
+
* see the [docs](../../how-to/data-strategy) for more information.
|
|
1724
|
+
*
|
|
1725
|
+
* ```tsx
|
|
1726
|
+
* let router = createBrowserRouter(routes, {
|
|
1727
|
+
* async dataStrategy({
|
|
1728
|
+
* matches,
|
|
1729
|
+
* request,
|
|
1730
|
+
* runClientMiddleware,
|
|
1731
|
+
* }) {
|
|
1732
|
+
* const matchesToLoad = matches.filter((m) =>
|
|
1733
|
+
* m.shouldCallHandler(),
|
|
1734
|
+
* );
|
|
1735
|
+
*
|
|
1736
|
+
* const results: Record<string, DataStrategyResult> = {};
|
|
1737
|
+
* await runClientMiddleware(() =>
|
|
1738
|
+
* Promise.all(
|
|
1739
|
+
* matchesToLoad.map(async (match) => {
|
|
1740
|
+
* results[match.route.id] = await match.resolve();
|
|
1741
|
+
* }),
|
|
1742
|
+
* ),
|
|
1743
|
+
* );
|
|
1744
|
+
* return results;
|
|
1745
|
+
* },
|
|
1746
|
+
* });
|
|
1747
|
+
* ```
|
|
1709
1748
|
*/
|
|
1710
1749
|
dataStrategy?: DataStrategyFunction;
|
|
1711
1750
|
/**
|
|
@@ -1743,6 +1782,7 @@ interface unstable_ClientOnErrorFunction {
|
|
|
1743
1782
|
(error: unknown, info: {
|
|
1744
1783
|
location: Location;
|
|
1745
1784
|
params: Params;
|
|
1785
|
+
unstable_pattern: string;
|
|
1746
1786
|
errorInfo?: React.ErrorInfo;
|
|
1747
1787
|
}): void;
|
|
1748
1788
|
}
|
|
@@ -1782,6 +1822,25 @@ interface RouterProviderProps {
|
|
|
1782
1822
|
* ```
|
|
1783
1823
|
*/
|
|
1784
1824
|
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
1825
|
+
/**
|
|
1826
|
+
* Control whether router state updates are internally wrapped in
|
|
1827
|
+
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
|
1828
|
+
*
|
|
1829
|
+
* - When left `undefined`, all state updates are wrapped in
|
|
1830
|
+
* `React.startTransition`
|
|
1831
|
+
* - This can lead to buggy behaviors if you are wrapping your own
|
|
1832
|
+
* navigations/fetchers in `startTransition`.
|
|
1833
|
+
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
|
1834
|
+
* in `React.startTransition` and router state changes will be wrapped in
|
|
1835
|
+
* `React.startTransition` and also sent through
|
|
1836
|
+
* [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
|
|
1837
|
+
* surface mid-navigation router state changes to the UI.
|
|
1838
|
+
* - When set to `false`, the router will not leverage `React.startTransition` or
|
|
1839
|
+
* `React.useOptimistic` on any navigations or state changes.
|
|
1840
|
+
*
|
|
1841
|
+
* For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
|
|
1842
|
+
*/
|
|
1843
|
+
unstable_useTransitions?: boolean;
|
|
1785
1844
|
}
|
|
1786
1845
|
/**
|
|
1787
1846
|
* Render the UI for the given {@link DataRouter}. This component should
|
|
@@ -1812,9 +1871,10 @@ interface RouterProviderProps {
|
|
|
1812
1871
|
* @param {RouterProviderProps.flushSync} props.flushSync n/a
|
|
1813
1872
|
* @param {RouterProviderProps.unstable_onError} props.unstable_onError n/a
|
|
1814
1873
|
* @param {RouterProviderProps.router} props.router n/a
|
|
1874
|
+
* @param {RouterProviderProps.unstable_useTransitions} props.unstable_useTransitions n/a
|
|
1815
1875
|
* @returns React element for the rendered router
|
|
1816
1876
|
*/
|
|
1817
|
-
declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, unstable_onError, }: RouterProviderProps): React.ReactElement;
|
|
1877
|
+
declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, unstable_onError, unstable_useTransitions, }: RouterProviderProps): React.ReactElement;
|
|
1818
1878
|
/**
|
|
1819
1879
|
* @category Types
|
|
1820
1880
|
*/
|
|
@@ -1835,6 +1895,21 @@ interface MemoryRouterProps {
|
|
|
1835
1895
|
* Index of `initialEntries` the application should initialize to
|
|
1836
1896
|
*/
|
|
1837
1897
|
initialIndex?: number;
|
|
1898
|
+
/**
|
|
1899
|
+
* Control whether router state updates are internally wrapped in
|
|
1900
|
+
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
|
1901
|
+
*
|
|
1902
|
+
* - When left `undefined`, all router state updates are wrapped in
|
|
1903
|
+
* `React.startTransition`
|
|
1904
|
+
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
|
1905
|
+
* in `React.startTransition` and all router state updates are wrapped in
|
|
1906
|
+
* `React.startTransition`
|
|
1907
|
+
* - When set to `false`, the router will not leverage `React.startTransition`
|
|
1908
|
+
* on any navigations or state changes.
|
|
1909
|
+
*
|
|
1910
|
+
* For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
|
|
1911
|
+
*/
|
|
1912
|
+
unstable_useTransitions?: boolean;
|
|
1838
1913
|
}
|
|
1839
1914
|
/**
|
|
1840
1915
|
* A declarative {@link Router | `<Router>`} that stores all entries in memory.
|
|
@@ -1847,10 +1922,11 @@ interface MemoryRouterProps {
|
|
|
1847
1922
|
* @param {MemoryRouterProps.children} props.children n/a
|
|
1848
1923
|
* @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
|
|
1849
1924
|
* @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
|
|
1925
|
+
* @param {MemoryRouterProps.unstable_useTransitions} props.unstable_useTransitions n/a
|
|
1850
1926
|
* @returns A declarative in-memory {@link Router | `<Router>`} for client-side
|
|
1851
1927
|
* routing.
|
|
1852
1928
|
*/
|
|
1853
|
-
declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
|
|
1929
|
+
declare function MemoryRouter({ basename, children, initialEntries, initialIndex, unstable_useTransitions, }: MemoryRouterProps): React.ReactElement;
|
|
1854
1930
|
/**
|
|
1855
1931
|
* @category Types
|
|
1856
1932
|
*/
|
|
@@ -2203,6 +2279,10 @@ interface RouterProps {
|
|
|
2203
2279
|
* will not be reactive to location changes.
|
|
2204
2280
|
*/
|
|
2205
2281
|
static?: boolean;
|
|
2282
|
+
/**
|
|
2283
|
+
* Whether this router should wrap navigations in `React.startTransition()`
|
|
2284
|
+
*/
|
|
2285
|
+
unstable_useTransitions: boolean;
|
|
2206
2286
|
}
|
|
2207
2287
|
/**
|
|
2208
2288
|
* Provides location context for the rest of the app.
|
|
@@ -2221,10 +2301,11 @@ interface RouterProps {
|
|
|
2221
2301
|
* @param {RouterProps.navigationType} props.navigationType n/a
|
|
2222
2302
|
* @param {RouterProps.navigator} props.navigator n/a
|
|
2223
2303
|
* @param {RouterProps.static} props.static n/a
|
|
2304
|
+
* @param {RouterProps.unstable_useTransitions} props.unstable_useTransitions n/a
|
|
2224
2305
|
* @returns React element for the rendered router or `null` if the location does
|
|
2225
2306
|
* not match the {@link props.basename}
|
|
2226
2307
|
*/
|
|
2227
|
-
declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
|
|
2308
|
+
declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, unstable_useTransitions, }: RouterProps): React.ReactElement | null;
|
|
2228
2309
|
/**
|
|
2229
2310
|
* @category Types
|
|
2230
2311
|
*/
|
|
@@ -2568,7 +2649,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
|
|
|
2568
2649
|
}
|
|
2569
2650
|
type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
|
|
2570
2651
|
type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
|
|
2571
|
-
interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
|
|
2652
|
+
interface DataRouterContextObject extends Omit<NavigationContextObject, "future" | "unstable_useTransitions"> {
|
|
2572
2653
|
router: Router$1;
|
|
2573
2654
|
staticContext?: StaticHandlerContext;
|
|
2574
2655
|
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
@@ -2622,6 +2703,7 @@ interface NavigationContextObject {
|
|
|
2622
2703
|
basename: string;
|
|
2623
2704
|
navigator: Navigator;
|
|
2624
2705
|
static: boolean;
|
|
2706
|
+
unstable_useTransitions: boolean;
|
|
2625
2707
|
future: {};
|
|
2626
2708
|
}
|
|
2627
2709
|
declare const NavigationContext: React.Context<NavigationContextObject>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteModule, h as LinkDescriptor, L as Location, F as Func, i as Pretty, j as MetaDescriptor, G as GetLoaderData, k as ServerDataFunctionArgs, l as MiddlewareNextFunction, m as ClientDataFunctionArgs, D as DataStrategyResult, n as ServerDataFrom, N as Normalize, o as GetActionData } from '../../router-
|
|
2
|
-
import { R as RouteFiles, P as Pages } from '../../register-
|
|
1
|
+
import { R as RouteModule, h as LinkDescriptor, L as Location, F as Func, i as Pretty, j as MetaDescriptor, G as GetLoaderData, k as ServerDataFunctionArgs, l as MiddlewareNextFunction, m as ClientDataFunctionArgs, D as DataStrategyResult, n as ServerDataFrom, N as Normalize, o as GetActionData } from '../../router-CwNp5l9u.mjs';
|
|
2
|
+
import { R as RouteFiles, P as Pages } from '../../register-C1RwVJAt.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteModule, f as LinkDescriptor, L as Location, F as Func, g as Pretty, h as MetaDescriptor, G as GetLoaderData, i as ServerDataFunctionArgs, j as MiddlewareNextFunction, k as ClientDataFunctionArgs, D as DataStrategyResult, l as ServerDataFrom, N as Normalize, m as GetActionData } from '../../instrumentation-
|
|
2
|
-
import { R as RouteFiles, P as Pages } from '../../register-
|
|
1
|
+
import { R as RouteModule, f as LinkDescriptor, L as Location, F as Func, g as Pretty, h as MetaDescriptor, G as GetLoaderData, i as ServerDataFunctionArgs, j as MiddlewareNextFunction, k as ClientDataFunctionArgs, D as DataStrategyResult, l as ServerDataFrom, N as Normalize, m as GetActionData } from '../../instrumentation-BB0wRuqz.js';
|
|
2
|
+
import { R as RouteFiles, P as Pages } from '../../register-ODDAAYlf.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RouteModule } from './instrumentation-
|
|
1
|
+
import { R as RouteModule } from './instrumentation-BB0wRuqz.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
|
@@ -541,6 +541,8 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
|
|
|
541
541
|
route: Promise<void> | undefined;
|
|
542
542
|
};
|
|
543
543
|
/**
|
|
544
|
+
* @deprecated Deprecated in favor of `shouldCallHandler`
|
|
545
|
+
*
|
|
544
546
|
* A boolean value indicating whether this route handler should be called in
|
|
545
547
|
* this pass.
|
|
546
548
|
*
|
|
@@ -566,8 +568,20 @@ interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRoute
|
|
|
566
568
|
* custom `shouldRevalidate` implementations)
|
|
567
569
|
*/
|
|
568
570
|
shouldLoad: boolean;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
+
/**
|
|
572
|
+
* Arguments passed to the `shouldRevalidate` function for this `loader` execution.
|
|
573
|
+
* Will be `null` if this is not a revalidating loader {@link DataStrategyMatch}.
|
|
574
|
+
*/
|
|
575
|
+
shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
|
|
576
|
+
/**
|
|
577
|
+
* Determine if this route's handler should be called during this `dataStrategy`
|
|
578
|
+
* execution. Calling it with no arguments will leverage the default revalidation
|
|
579
|
+
* behavior. You can pass your own `defaultShouldRevalidate` value if you wish
|
|
580
|
+
* to change the default revalidation behavior with your `dataStrategy`.
|
|
581
|
+
*
|
|
582
|
+
* @param defaultShouldRevalidate `defaultShouldRevalidate` override value (optional)
|
|
583
|
+
*/
|
|
584
|
+
shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
|
|
571
585
|
/**
|
|
572
586
|
* An async function that will resolve any `route.lazy` implementations and
|
|
573
587
|
* execute the route's handler (if necessary), returning a {@link DataStrategyResult}
|
|
@@ -1015,7 +1029,8 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
1015
1029
|
/**
|
|
1016
1030
|
* Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
|
|
1017
1031
|
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1018
|
-
* thrown from an [`action`](../../start/framework/route-module#action)
|
|
1032
|
+
* thrown from an [`action`](../../start/framework/route-module#action) or
|
|
1033
|
+
* [`loader`](../../start/framework/route-module#loader) function.
|
|
1019
1034
|
*
|
|
1020
1035
|
* @example
|
|
1021
1036
|
* import { isRouteErrorResponse } from "react-router";
|
|
@@ -1041,7 +1056,6 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
1041
1056
|
* @mode data
|
|
1042
1057
|
* @param error The error to check.
|
|
1043
1058
|
* @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
|
|
1044
|
-
*
|
|
1045
1059
|
*/
|
|
1046
1060
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
1047
1061
|
|
|
@@ -1098,7 +1112,7 @@ interface MemoryRouterOpts {
|
|
|
1098
1112
|
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
1099
1113
|
* mostly useful for observability such as wrapping navigations, fetches,
|
|
1100
1114
|
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
1101
|
-
* tracing.
|
|
1115
|
+
* tracing. See the [docs](../../how-to/instrumentation) for more information.
|
|
1102
1116
|
*
|
|
1103
1117
|
* ```tsx
|
|
1104
1118
|
* let router = createBrowserRouter(routes, {
|
|
@@ -1142,8 +1156,32 @@ interface MemoryRouterOpts {
|
|
|
1142
1156
|
*/
|
|
1143
1157
|
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
1144
1158
|
/**
|
|
1145
|
-
* Override the default data strategy of
|
|
1146
|
-
*
|
|
1159
|
+
* Override the default data strategy of running loaders in parallel -
|
|
1160
|
+
* see the [docs](../../how-to/data-strategy) for more information.
|
|
1161
|
+
*
|
|
1162
|
+
* ```tsx
|
|
1163
|
+
* let router = createBrowserRouter(routes, {
|
|
1164
|
+
* async dataStrategy({
|
|
1165
|
+
* matches,
|
|
1166
|
+
* request,
|
|
1167
|
+
* runClientMiddleware,
|
|
1168
|
+
* }) {
|
|
1169
|
+
* const matchesToLoad = matches.filter((m) =>
|
|
1170
|
+
* m.shouldCallHandler(),
|
|
1171
|
+
* );
|
|
1172
|
+
*
|
|
1173
|
+
* const results: Record<string, DataStrategyResult> = {};
|
|
1174
|
+
* await runClientMiddleware(() =>
|
|
1175
|
+
* Promise.all(
|
|
1176
|
+
* matchesToLoad.map(async (match) => {
|
|
1177
|
+
* results[match.route.id] = await match.resolve();
|
|
1178
|
+
* }),
|
|
1179
|
+
* ),
|
|
1180
|
+
* );
|
|
1181
|
+
* return results;
|
|
1182
|
+
* },
|
|
1183
|
+
* });
|
|
1184
|
+
* ```
|
|
1147
1185
|
*/
|
|
1148
1186
|
dataStrategy?: DataStrategyFunction;
|
|
1149
1187
|
/**
|
|
@@ -1181,6 +1219,7 @@ interface unstable_ClientOnErrorFunction {
|
|
|
1181
1219
|
(error: unknown, info: {
|
|
1182
1220
|
location: Location;
|
|
1183
1221
|
params: Params;
|
|
1222
|
+
unstable_pattern: string;
|
|
1184
1223
|
errorInfo?: React.ErrorInfo;
|
|
1185
1224
|
}): void;
|
|
1186
1225
|
}
|
|
@@ -1220,6 +1259,25 @@ interface RouterProviderProps {
|
|
|
1220
1259
|
* ```
|
|
1221
1260
|
*/
|
|
1222
1261
|
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
1262
|
+
/**
|
|
1263
|
+
* Control whether router state updates are internally wrapped in
|
|
1264
|
+
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
|
1265
|
+
*
|
|
1266
|
+
* - When left `undefined`, all state updates are wrapped in
|
|
1267
|
+
* `React.startTransition`
|
|
1268
|
+
* - This can lead to buggy behaviors if you are wrapping your own
|
|
1269
|
+
* navigations/fetchers in `startTransition`.
|
|
1270
|
+
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
|
1271
|
+
* in `React.startTransition` and router state changes will be wrapped in
|
|
1272
|
+
* `React.startTransition` and also sent through
|
|
1273
|
+
* [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
|
|
1274
|
+
* surface mid-navigation router state changes to the UI.
|
|
1275
|
+
* - When set to `false`, the router will not leverage `React.startTransition` or
|
|
1276
|
+
* `React.useOptimistic` on any navigations or state changes.
|
|
1277
|
+
*
|
|
1278
|
+
* For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
|
|
1279
|
+
*/
|
|
1280
|
+
unstable_useTransitions?: boolean;
|
|
1223
1281
|
}
|
|
1224
1282
|
/**
|
|
1225
1283
|
* Render the UI for the given {@link DataRouter}. This component should
|
|
@@ -1250,9 +1308,10 @@ interface RouterProviderProps {
|
|
|
1250
1308
|
* @param {RouterProviderProps.flushSync} props.flushSync n/a
|
|
1251
1309
|
* @param {RouterProviderProps.unstable_onError} props.unstable_onError n/a
|
|
1252
1310
|
* @param {RouterProviderProps.router} props.router n/a
|
|
1311
|
+
* @param {RouterProviderProps.unstable_useTransitions} props.unstable_useTransitions n/a
|
|
1253
1312
|
* @returns React element for the rendered router
|
|
1254
1313
|
*/
|
|
1255
|
-
declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, unstable_onError, }: RouterProviderProps): React.ReactElement;
|
|
1314
|
+
declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, unstable_onError, unstable_useTransitions, }: RouterProviderProps): React.ReactElement;
|
|
1256
1315
|
/**
|
|
1257
1316
|
* @category Types
|
|
1258
1317
|
*/
|
|
@@ -1273,6 +1332,21 @@ interface MemoryRouterProps {
|
|
|
1273
1332
|
* Index of `initialEntries` the application should initialize to
|
|
1274
1333
|
*/
|
|
1275
1334
|
initialIndex?: number;
|
|
1335
|
+
/**
|
|
1336
|
+
* Control whether router state updates are internally wrapped in
|
|
1337
|
+
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
|
1338
|
+
*
|
|
1339
|
+
* - When left `undefined`, all router state updates are wrapped in
|
|
1340
|
+
* `React.startTransition`
|
|
1341
|
+
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
|
1342
|
+
* in `React.startTransition` and all router state updates are wrapped in
|
|
1343
|
+
* `React.startTransition`
|
|
1344
|
+
* - When set to `false`, the router will not leverage `React.startTransition`
|
|
1345
|
+
* on any navigations or state changes.
|
|
1346
|
+
*
|
|
1347
|
+
* For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
|
|
1348
|
+
*/
|
|
1349
|
+
unstable_useTransitions?: boolean;
|
|
1276
1350
|
}
|
|
1277
1351
|
/**
|
|
1278
1352
|
* A declarative {@link Router | `<Router>`} that stores all entries in memory.
|
|
@@ -1285,10 +1359,11 @@ interface MemoryRouterProps {
|
|
|
1285
1359
|
* @param {MemoryRouterProps.children} props.children n/a
|
|
1286
1360
|
* @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
|
|
1287
1361
|
* @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
|
|
1362
|
+
* @param {MemoryRouterProps.unstable_useTransitions} props.unstable_useTransitions n/a
|
|
1288
1363
|
* @returns A declarative in-memory {@link Router | `<Router>`} for client-side
|
|
1289
1364
|
* routing.
|
|
1290
1365
|
*/
|
|
1291
|
-
declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
|
|
1366
|
+
declare function MemoryRouter({ basename, children, initialEntries, initialIndex, unstable_useTransitions, }: MemoryRouterProps): React.ReactElement;
|
|
1292
1367
|
/**
|
|
1293
1368
|
* @category Types
|
|
1294
1369
|
*/
|
|
@@ -1641,6 +1716,10 @@ interface RouterProps {
|
|
|
1641
1716
|
* will not be reactive to location changes.
|
|
1642
1717
|
*/
|
|
1643
1718
|
static?: boolean;
|
|
1719
|
+
/**
|
|
1720
|
+
* Whether this router should wrap navigations in `React.startTransition()`
|
|
1721
|
+
*/
|
|
1722
|
+
unstable_useTransitions: boolean;
|
|
1644
1723
|
}
|
|
1645
1724
|
/**
|
|
1646
1725
|
* Provides location context for the rest of the app.
|
|
@@ -1659,10 +1738,11 @@ interface RouterProps {
|
|
|
1659
1738
|
* @param {RouterProps.navigationType} props.navigationType n/a
|
|
1660
1739
|
* @param {RouterProps.navigator} props.navigator n/a
|
|
1661
1740
|
* @param {RouterProps.static} props.static n/a
|
|
1741
|
+
* @param {RouterProps.unstable_useTransitions} props.unstable_useTransitions n/a
|
|
1662
1742
|
* @returns React element for the rendered router or `null` if the location does
|
|
1663
1743
|
* not match the {@link props.basename}
|
|
1664
1744
|
*/
|
|
1665
|
-
declare function Router$1({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
|
|
1745
|
+
declare function Router$1({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, unstable_useTransitions, }: RouterProps): React.ReactElement | null;
|
|
1666
1746
|
/**
|
|
1667
1747
|
* @category Types
|
|
1668
1748
|
*/
|
|
@@ -2006,7 +2086,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
|
|
|
2006
2086
|
}
|
|
2007
2087
|
type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
|
|
2008
2088
|
type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
|
|
2009
|
-
interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
|
|
2089
|
+
interface DataRouterContextObject extends Omit<NavigationContextObject, "future" | "unstable_useTransitions"> {
|
|
2010
2090
|
router: Router;
|
|
2011
2091
|
staticContext?: StaticHandlerContext;
|
|
2012
2092
|
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
@@ -2060,6 +2140,7 @@ interface NavigationContextObject {
|
|
|
2060
2140
|
basename: string;
|
|
2061
2141
|
navigator: Navigator;
|
|
2062
2142
|
static: boolean;
|
|
2143
|
+
unstable_useTransitions: boolean;
|
|
2063
2144
|
future: {};
|
|
2064
2145
|
}
|
|
2065
2146
|
declare const NavigationContext: React.Context<NavigationContextObject>;
|
|
@@ -2966,6 +3047,7 @@ type ViewTransitionOpts = {
|
|
|
2966
3047
|
interface RouterSubscriber {
|
|
2967
3048
|
(state: RouterState, opts: {
|
|
2968
3049
|
deletedFetchers: string[];
|
|
3050
|
+
newErrors: RouteData | null;
|
|
2969
3051
|
viewTransitionOpts?: ViewTransitionOpts;
|
|
2970
3052
|
flushSync: boolean;
|
|
2971
3053
|
}): void;
|