react-router 7.8.1 → 7.8.2-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 +23 -0
- package/dist/development/{chunk-IFMMFE4R.mjs → chunk-7QFLQWWN.mjs} +34 -75
- package/dist/{production/chunk-YMYXECPK.js → development/chunk-IVOVRAK2.js} +210 -169
- package/dist/development/{chunk-UH6JLGW7.mjs → chunk-ZVD2KUIM.mjs} +187 -204
- package/dist/development/{chunk-TGXCWGPT.js → chunk-ZVMYUFGA.js} +125 -183
- package/dist/development/{context-DohQKLID.d.mts → context-jKip1TFB.d.mts} +846 -8
- package/dist/development/dom-export.d.mts +20 -2
- package/dist/development/dom-export.d.ts +20 -1
- package/dist/development/dom-export.js +10 -4
- package/dist/development/dom-export.mjs +10 -4
- package/dist/{production/index-react-server-client-BQ6FxdA_.d.ts → development/index-react-server-client-BKpa2trA.d.ts} +6 -816
- package/dist/{production/index-react-server-client-11fLy3qB.d.mts → development/index-react-server-client-DRhjXpk2.d.mts} +2 -3
- package/dist/development/index-react-server-client.d.mts +3 -4
- 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 +4 -3
- package/dist/development/index-react-server.d.ts +4 -3
- package/dist/development/index-react-server.js +62 -53
- package/dist/development/index-react-server.mjs +62 -53
- package/dist/development/index.d.mts +7 -9
- package/dist/development/index.d.ts +5 -5
- package/dist/development/index.js +122 -163
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +3 -3
- 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/{route-data-CNjObrhZ.d.mts → route-data-DAVP2QQ0.d.mts} +3 -3
- package/dist/development/{routeModules-C3oqzPpI.d.ts → routeModules-rOzWJJ9x.d.ts} +848 -10
- package/dist/production/{chunk-KHPQXKYM.js → chunk-5WPGWA23.js} +125 -183
- package/dist/{development/chunk-IIA3TUI2.js → production/chunk-IK7IYG3O.js} +210 -169
- package/dist/production/{chunk-5Y7ELDIJ.mjs → chunk-LR4OTIMG.mjs} +34 -75
- package/dist/production/{chunk-PFDCNQUK.mjs → chunk-VHBXOG2Z.mjs} +187 -204
- package/dist/production/{context-DohQKLID.d.mts → context-jKip1TFB.d.mts} +846 -8
- package/dist/production/dom-export.d.mts +20 -2
- package/dist/production/dom-export.d.ts +20 -1
- package/dist/production/dom-export.js +10 -4
- package/dist/production/dom-export.mjs +10 -4
- package/dist/{development/index-react-server-client-BQ6FxdA_.d.ts → production/index-react-server-client-BKpa2trA.d.ts} +6 -816
- package/dist/{development/index-react-server-client-11fLy3qB.d.mts → production/index-react-server-client-DRhjXpk2.d.mts} +2 -3
- package/dist/production/index-react-server-client.d.mts +3 -4
- 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 +4 -3
- package/dist/production/index-react-server.d.ts +4 -3
- package/dist/production/index-react-server.js +62 -53
- package/dist/production/index-react-server.mjs +62 -53
- package/dist/production/index.d.mts +7 -9
- package/dist/production/index.d.ts +5 -5
- package/dist/production/index.js +122 -163
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +3 -3
- 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/{route-data-CNjObrhZ.d.mts → route-data-DAVP2QQ0.d.mts} +3 -3
- package/dist/production/{routeModules-C3oqzPpI.d.ts → routeModules-rOzWJJ9x.d.ts} +848 -10
- package/package.json +1 -1
- package/dist/development/components-CuPfnyiZ.d.mts +0 -814
- package/dist/production/components-CuPfnyiZ.d.mts +0 -814
|
@@ -1038,7 +1038,7 @@ declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
|
1038
1038
|
/**
|
|
1039
1039
|
* A Router instance manages all navigation and data loading/mutations
|
|
1040
1040
|
*/
|
|
1041
|
-
interface Router {
|
|
1041
|
+
interface Router$1 {
|
|
1042
1042
|
/**
|
|
1043
1043
|
* @private
|
|
1044
1044
|
* PRIVATE - DO NOT USE
|
|
@@ -1082,7 +1082,7 @@ interface Router {
|
|
|
1082
1082
|
* initial data fetches. Returns a function to cleanup listeners and abort
|
|
1083
1083
|
* any in-progress loads
|
|
1084
1084
|
*/
|
|
1085
|
-
initialize(): Router;
|
|
1085
|
+
initialize(): Router$1;
|
|
1086
1086
|
/**
|
|
1087
1087
|
* @private
|
|
1088
1088
|
* PRIVATE - DO NOT USE
|
|
@@ -1300,7 +1300,6 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1300
1300
|
* Future flags to toggle new feature behavior
|
|
1301
1301
|
*/
|
|
1302
1302
|
interface FutureConfig {
|
|
1303
|
-
unstable_middleware: boolean;
|
|
1304
1303
|
}
|
|
1305
1304
|
/**
|
|
1306
1305
|
* Initialization options for createRouter
|
|
@@ -1322,7 +1321,7 @@ interface RouterInit {
|
|
|
1322
1321
|
* State returned from a server-side query() call
|
|
1323
1322
|
*/
|
|
1324
1323
|
interface StaticHandlerContext {
|
|
1325
|
-
basename: Router["basename"];
|
|
1324
|
+
basename: Router$1["basename"];
|
|
1326
1325
|
location: RouterState["location"];
|
|
1327
1326
|
matches: RouterState["matches"];
|
|
1328
1327
|
loaderData: RouterState["loaderData"];
|
|
@@ -1344,7 +1343,9 @@ interface StaticHandler {
|
|
|
1344
1343
|
skipLoaderErrorBubbling?: boolean;
|
|
1345
1344
|
skipRevalidation?: boolean;
|
|
1346
1345
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1347
|
-
unstable_generateMiddlewareResponse?: (query: (r: Request
|
|
1346
|
+
unstable_generateMiddlewareResponse?: (query: (r: Request, args?: {
|
|
1347
|
+
filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
|
|
1348
|
+
}) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1348
1349
|
}): Promise<StaticHandlerContext | Response>;
|
|
1349
1350
|
queryRoute(request: Request, opts?: {
|
|
1350
1351
|
routeId?: string;
|
|
@@ -1577,7 +1578,7 @@ declare const IDLE_BLOCKER: BlockerUnblocked;
|
|
|
1577
1578
|
/**
|
|
1578
1579
|
* Create a router and listen to history POP navigations
|
|
1579
1580
|
*/
|
|
1580
|
-
declare function createRouter(init: RouterInit): Router;
|
|
1581
|
+
declare function createRouter(init: RouterInit): Router$1;
|
|
1581
1582
|
interface CreateStaticHandlerOptions {
|
|
1582
1583
|
basename?: string;
|
|
1583
1584
|
mapRouteProperties?: MapRoutePropertiesFunction;
|
|
@@ -1636,8 +1637,9 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
|
|
|
1636
1637
|
type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
|
|
1637
1638
|
type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
|
|
1638
1639
|
interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
|
|
1639
|
-
router: Router;
|
|
1640
|
+
router: Router$1;
|
|
1640
1641
|
staticContext?: StaticHandlerContext;
|
|
1642
|
+
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
1641
1643
|
}
|
|
1642
1644
|
declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
|
|
1643
1645
|
declare const DataRouterStateContext: React.Context<RouterState | null>;
|
|
@@ -1701,6 +1703,842 @@ interface RouteContextObject {
|
|
|
1701
1703
|
}
|
|
1702
1704
|
declare const RouteContext: React.Context<RouteContextObject>;
|
|
1703
1705
|
|
|
1706
|
+
declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
|
|
1707
|
+
hasErrorBoundary: boolean;
|
|
1708
|
+
};
|
|
1709
|
+
declare const hydrationRouteProperties: (keyof RouteObject)[];
|
|
1710
|
+
/**
|
|
1711
|
+
* @category Data Routers
|
|
1712
|
+
*/
|
|
1713
|
+
interface MemoryRouterOpts {
|
|
1714
|
+
/**
|
|
1715
|
+
* Basename path for the application.
|
|
1716
|
+
*/
|
|
1717
|
+
basename?: string;
|
|
1718
|
+
/**
|
|
1719
|
+
* A function that returns an {@link unstable_RouterContextProvider} instance
|
|
1720
|
+
* which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
|
|
1721
|
+
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
|
1722
|
+
* This function is called to generate a fresh `context` instance on each
|
|
1723
|
+
* navigation or fetcher call.
|
|
1724
|
+
*/
|
|
1725
|
+
unstable_getContext?: RouterInit["unstable_getContext"];
|
|
1726
|
+
/**
|
|
1727
|
+
* Future flags to enable for the router.
|
|
1728
|
+
*/
|
|
1729
|
+
future?: Partial<FutureConfig>;
|
|
1730
|
+
/**
|
|
1731
|
+
* Hydration data to initialize the router with if you have already performed
|
|
1732
|
+
* data loading on the server.
|
|
1733
|
+
*/
|
|
1734
|
+
hydrationData?: HydrationState;
|
|
1735
|
+
/**
|
|
1736
|
+
* Initial entries in the in-memory history stack
|
|
1737
|
+
*/
|
|
1738
|
+
initialEntries?: InitialEntry[];
|
|
1739
|
+
/**
|
|
1740
|
+
* Index of `initialEntries` the application should initialize to
|
|
1741
|
+
*/
|
|
1742
|
+
initialIndex?: number;
|
|
1743
|
+
/**
|
|
1744
|
+
* Override the default data strategy of loading in parallel.
|
|
1745
|
+
* Only intended for advanced usage.
|
|
1746
|
+
*/
|
|
1747
|
+
dataStrategy?: DataStrategyFunction;
|
|
1748
|
+
/**
|
|
1749
|
+
* Lazily define portions of the route tree on navigations.
|
|
1750
|
+
*/
|
|
1751
|
+
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Create a new {@link DataRouter} that manages the application path using an
|
|
1755
|
+
* in-memory [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
|
1756
|
+
* stack. Useful for non-browser environments without a DOM API.
|
|
1757
|
+
*
|
|
1758
|
+
* @public
|
|
1759
|
+
* @category Data Routers
|
|
1760
|
+
* @mode data
|
|
1761
|
+
* @param routes Application routes
|
|
1762
|
+
* @param opts Options
|
|
1763
|
+
* @param {MemoryRouterOpts.basename} opts.basename n/a
|
|
1764
|
+
* @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
|
|
1765
|
+
* @param {MemoryRouterOpts.future} opts.future n/a
|
|
1766
|
+
* @param {MemoryRouterOpts.unstable_getContext} opts.unstable_getContext n/a
|
|
1767
|
+
* @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
|
|
1768
|
+
* @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
|
|
1769
|
+
* @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
|
|
1770
|
+
* @param {MemoryRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
|
|
1771
|
+
* @returns An initialized {@link DataRouter} to pass to {@link RouterProvider | `<RouterProvider>`}
|
|
1772
|
+
*/
|
|
1773
|
+
declare function createMemoryRouter(routes: RouteObject[], opts?: MemoryRouterOpts): Router$1;
|
|
1774
|
+
/**
|
|
1775
|
+
* Function signature for client side error handling for loader/actions errors
|
|
1776
|
+
* and rendering errors via `componentDidCatch`
|
|
1777
|
+
*/
|
|
1778
|
+
interface unstable_ClientOnErrorFunction {
|
|
1779
|
+
(error: unknown, errorInfo?: React.ErrorInfo): void;
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* @category Types
|
|
1783
|
+
*/
|
|
1784
|
+
interface RouterProviderProps {
|
|
1785
|
+
/**
|
|
1786
|
+
* The {@link DataRouter} instance to use for navigation and data fetching.
|
|
1787
|
+
*/
|
|
1788
|
+
router: Router$1;
|
|
1789
|
+
/**
|
|
1790
|
+
* The [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
|
|
1791
|
+
* implementation to use for flushing updates.
|
|
1792
|
+
*
|
|
1793
|
+
* You usually don't have to worry about this:
|
|
1794
|
+
* - The `RouterProvider` exported from `react-router/dom` handles this internally for you
|
|
1795
|
+
* - If you are rendering in a non-DOM environment, you can import
|
|
1796
|
+
* `RouterProvider` from `react-router` and ignore this prop
|
|
1797
|
+
*/
|
|
1798
|
+
flushSync?: (fn: () => unknown) => undefined;
|
|
1799
|
+
/**
|
|
1800
|
+
* An error handler function that will be called for any loader/action/render
|
|
1801
|
+
* errors that are encountered in your application. This is useful for
|
|
1802
|
+
* logging or reporting errors instead of the `ErrorBoundary` because it's not
|
|
1803
|
+
* subject to re-rendering and will only run one time per error.
|
|
1804
|
+
*
|
|
1805
|
+
* The `errorInfo` parameter is passed along from
|
|
1806
|
+
* [`componentDidCatch`](https://react.dev/reference/react/Component#componentdidcatch)
|
|
1807
|
+
* and is only present for render errors.
|
|
1808
|
+
*
|
|
1809
|
+
* ```tsx
|
|
1810
|
+
* <RouterProvider unstable_onError=(error, errorInfo) => {
|
|
1811
|
+
* console.error(error, errorInfo);
|
|
1812
|
+
* reportToErrorService(error, errorInfo);
|
|
1813
|
+
* }} />
|
|
1814
|
+
* ```
|
|
1815
|
+
*/
|
|
1816
|
+
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Render the UI for the given {@link DataRouter}. This component should
|
|
1820
|
+
* typically be at the top of an app's element tree.
|
|
1821
|
+
*
|
|
1822
|
+
* ```tsx
|
|
1823
|
+
* import { createBrowserRouter } from "react-router";
|
|
1824
|
+
* import { RouterProvider } from "react-router/dom";
|
|
1825
|
+
* import { createRoot } from "react-dom/client";
|
|
1826
|
+
*
|
|
1827
|
+
* const router = createBrowserRouter(routes);
|
|
1828
|
+
* createRoot(document.getElementById("root")).render(
|
|
1829
|
+
* <RouterProvider router={router} />
|
|
1830
|
+
* );
|
|
1831
|
+
* ```
|
|
1832
|
+
*
|
|
1833
|
+
* <docs-info>Please note that this component is exported both from
|
|
1834
|
+
* `react-router` and `react-router/dom` with the only difference being that the
|
|
1835
|
+
* latter automatically wires up `react-dom`'s [`flushSync`](https://react.dev/reference/react-dom/flushSync)
|
|
1836
|
+
* implementation. You _almost always_ want to use the version from
|
|
1837
|
+
* `react-router/dom` unless you're running in a non-DOM environment.</docs-info>
|
|
1838
|
+
*
|
|
1839
|
+
*
|
|
1840
|
+
* @public
|
|
1841
|
+
* @category Data Routers
|
|
1842
|
+
* @mode data
|
|
1843
|
+
* @param props Props
|
|
1844
|
+
* @param {RouterProviderProps.flushSync} props.flushSync n/a
|
|
1845
|
+
* @param {RouterProviderProps.unstable_onError} props.unstable_onError n/a
|
|
1846
|
+
* @param {RouterProviderProps.router} props.router n/a
|
|
1847
|
+
* @returns React element for the rendered router
|
|
1848
|
+
*/
|
|
1849
|
+
declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, unstable_onError, }: RouterProviderProps): React.ReactElement;
|
|
1850
|
+
/**
|
|
1851
|
+
* @category Types
|
|
1852
|
+
*/
|
|
1853
|
+
interface MemoryRouterProps {
|
|
1854
|
+
/**
|
|
1855
|
+
* Application basename
|
|
1856
|
+
*/
|
|
1857
|
+
basename?: string;
|
|
1858
|
+
/**
|
|
1859
|
+
* Nested {@link Route} elements describing the route tree
|
|
1860
|
+
*/
|
|
1861
|
+
children?: React.ReactNode;
|
|
1862
|
+
/**
|
|
1863
|
+
* Initial entries in the in-memory history stack
|
|
1864
|
+
*/
|
|
1865
|
+
initialEntries?: InitialEntry[];
|
|
1866
|
+
/**
|
|
1867
|
+
* Index of `initialEntries` the application should initialize to
|
|
1868
|
+
*/
|
|
1869
|
+
initialIndex?: number;
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* A declarative {@link Router | `<Router>`} that stores all entries in memory.
|
|
1873
|
+
*
|
|
1874
|
+
* @public
|
|
1875
|
+
* @category Declarative Routers
|
|
1876
|
+
* @mode declarative
|
|
1877
|
+
* @param props Props
|
|
1878
|
+
* @param {MemoryRouterProps.basename} props.basename n/a
|
|
1879
|
+
* @param {MemoryRouterProps.children} props.children n/a
|
|
1880
|
+
* @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
|
|
1881
|
+
* @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
|
|
1882
|
+
* @returns A declarative in-memory {@link Router | `<Router>`} for client-side
|
|
1883
|
+
* routing.
|
|
1884
|
+
*/
|
|
1885
|
+
declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
|
|
1886
|
+
/**
|
|
1887
|
+
* @category Types
|
|
1888
|
+
*/
|
|
1889
|
+
interface NavigateProps {
|
|
1890
|
+
/**
|
|
1891
|
+
* The path to navigate to. This can be a string or a {@link Path} object
|
|
1892
|
+
*/
|
|
1893
|
+
to: To;
|
|
1894
|
+
/**
|
|
1895
|
+
* Whether to replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
|
1896
|
+
* stack
|
|
1897
|
+
*/
|
|
1898
|
+
replace?: boolean;
|
|
1899
|
+
/**
|
|
1900
|
+
* State to pass to the new {@link Location} to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
|
|
1901
|
+
*/
|
|
1902
|
+
state?: any;
|
|
1903
|
+
/**
|
|
1904
|
+
* How to interpret relative routing in the `to` prop.
|
|
1905
|
+
* See {@link RelativeRoutingType}.
|
|
1906
|
+
*/
|
|
1907
|
+
relative?: RelativeRoutingType;
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* A component-based version of {@link useNavigate} to use in a
|
|
1911
|
+
* [`React.Component` class](https://react.dev/reference/react/Component) where
|
|
1912
|
+
* hooks cannot be used.
|
|
1913
|
+
*
|
|
1914
|
+
* It's recommended to avoid using this component in favor of {@link useNavigate}.
|
|
1915
|
+
*
|
|
1916
|
+
* @example
|
|
1917
|
+
* <Navigate to="/tasks" />
|
|
1918
|
+
*
|
|
1919
|
+
* @public
|
|
1920
|
+
* @category Components
|
|
1921
|
+
* @param props Props
|
|
1922
|
+
* @param {NavigateProps.relative} props.relative n/a
|
|
1923
|
+
* @param {NavigateProps.replace} props.replace n/a
|
|
1924
|
+
* @param {NavigateProps.state} props.state n/a
|
|
1925
|
+
* @param {NavigateProps.to} props.to n/a
|
|
1926
|
+
* @returns {void}
|
|
1927
|
+
*
|
|
1928
|
+
*/
|
|
1929
|
+
declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
|
|
1930
|
+
/**
|
|
1931
|
+
* @category Types
|
|
1932
|
+
*/
|
|
1933
|
+
interface OutletProps {
|
|
1934
|
+
/**
|
|
1935
|
+
* Provides a context value to the element tree below the outlet. Use when
|
|
1936
|
+
* the parent route needs to provide values to child routes.
|
|
1937
|
+
*
|
|
1938
|
+
* ```tsx
|
|
1939
|
+
* <Outlet context={myContextValue} />
|
|
1940
|
+
* ```
|
|
1941
|
+
*
|
|
1942
|
+
* Access the context with {@link useOutletContext}.
|
|
1943
|
+
*/
|
|
1944
|
+
context?: unknown;
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* Renders the matching child route of a parent route or nothing if no child
|
|
1948
|
+
* route matches.
|
|
1949
|
+
*
|
|
1950
|
+
* @example
|
|
1951
|
+
* import { Outlet } from "react-router";
|
|
1952
|
+
*
|
|
1953
|
+
* export default function SomeParent() {
|
|
1954
|
+
* return (
|
|
1955
|
+
* <div>
|
|
1956
|
+
* <h1>Parent Content</h1>
|
|
1957
|
+
* <Outlet />
|
|
1958
|
+
* </div>
|
|
1959
|
+
* );
|
|
1960
|
+
* }
|
|
1961
|
+
*
|
|
1962
|
+
* @public
|
|
1963
|
+
* @category Components
|
|
1964
|
+
* @param props Props
|
|
1965
|
+
* @param {OutletProps.context} props.context n/a
|
|
1966
|
+
* @returns React element for the rendered outlet or `null` if no child route matches.
|
|
1967
|
+
*/
|
|
1968
|
+
declare function Outlet(props: OutletProps): React.ReactElement | null;
|
|
1969
|
+
/**
|
|
1970
|
+
* @category Types
|
|
1971
|
+
*/
|
|
1972
|
+
interface PathRouteProps {
|
|
1973
|
+
/**
|
|
1974
|
+
* Whether the path should be case-sensitive. Defaults to `false`.
|
|
1975
|
+
*/
|
|
1976
|
+
caseSensitive?: NonIndexRouteObject["caseSensitive"];
|
|
1977
|
+
/**
|
|
1978
|
+
* The path pattern to match. If unspecified or empty, then this becomes a
|
|
1979
|
+
* layout route.
|
|
1980
|
+
*/
|
|
1981
|
+
path?: NonIndexRouteObject["path"];
|
|
1982
|
+
/**
|
|
1983
|
+
* The unique identifier for this route (for use with {@link DataRouter}s)
|
|
1984
|
+
*/
|
|
1985
|
+
id?: NonIndexRouteObject["id"];
|
|
1986
|
+
/**
|
|
1987
|
+
* A function that returns a promise that resolves to the route object.
|
|
1988
|
+
* Used for code-splitting routes.
|
|
1989
|
+
* See [`lazy`](../../start/data/route-object#lazy).
|
|
1990
|
+
*/
|
|
1991
|
+
lazy?: LazyRouteFunction<NonIndexRouteObject>;
|
|
1992
|
+
/**
|
|
1993
|
+
* The route loader.
|
|
1994
|
+
* See [`loader`](../../start/data/route-object#loader).
|
|
1995
|
+
*/
|
|
1996
|
+
loader?: NonIndexRouteObject["loader"];
|
|
1997
|
+
/**
|
|
1998
|
+
* The route action.
|
|
1999
|
+
* See [`action`](../../start/data/route-object#action).
|
|
2000
|
+
*/
|
|
2001
|
+
action?: NonIndexRouteObject["action"];
|
|
2002
|
+
hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
|
|
2003
|
+
/**
|
|
2004
|
+
* The route shouldRevalidate function.
|
|
2005
|
+
* See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
|
|
2006
|
+
*/
|
|
2007
|
+
shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
|
|
2008
|
+
/**
|
|
2009
|
+
* The route handle.
|
|
2010
|
+
*/
|
|
2011
|
+
handle?: NonIndexRouteObject["handle"];
|
|
2012
|
+
/**
|
|
2013
|
+
* Whether this is an index route.
|
|
2014
|
+
*/
|
|
2015
|
+
index?: false;
|
|
2016
|
+
/**
|
|
2017
|
+
* Child Route components
|
|
2018
|
+
*/
|
|
2019
|
+
children?: React.ReactNode;
|
|
2020
|
+
/**
|
|
2021
|
+
* The React element to render when this Route matches.
|
|
2022
|
+
* Mutually exclusive with `Component`.
|
|
2023
|
+
*/
|
|
2024
|
+
element?: React.ReactNode | null;
|
|
2025
|
+
/**
|
|
2026
|
+
* The React element to render while this router is loading data.
|
|
2027
|
+
* Mutually exclusive with `HydrateFallback`.
|
|
2028
|
+
*/
|
|
2029
|
+
hydrateFallbackElement?: React.ReactNode | null;
|
|
2030
|
+
/**
|
|
2031
|
+
* The React element to render at this route if an error occurs.
|
|
2032
|
+
* Mutually exclusive with `ErrorBoundary`.
|
|
2033
|
+
*/
|
|
2034
|
+
errorElement?: React.ReactNode | null;
|
|
2035
|
+
/**
|
|
2036
|
+
* The React Component to render when this route matches.
|
|
2037
|
+
* Mutually exclusive with `element`.
|
|
2038
|
+
*/
|
|
2039
|
+
Component?: React.ComponentType | null;
|
|
2040
|
+
/**
|
|
2041
|
+
* The React Component to render while this router is loading data.
|
|
2042
|
+
* Mutually exclusive with `hydrateFallbackElement`.
|
|
2043
|
+
*/
|
|
2044
|
+
HydrateFallback?: React.ComponentType | null;
|
|
2045
|
+
/**
|
|
2046
|
+
* The React Component to render at this route if an error occurs.
|
|
2047
|
+
* Mutually exclusive with `errorElement`.
|
|
2048
|
+
*/
|
|
2049
|
+
ErrorBoundary?: React.ComponentType | null;
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* @category Types
|
|
2053
|
+
*/
|
|
2054
|
+
interface LayoutRouteProps extends PathRouteProps {
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* @category Types
|
|
2058
|
+
*/
|
|
2059
|
+
interface IndexRouteProps {
|
|
2060
|
+
/**
|
|
2061
|
+
* Whether the path should be case-sensitive. Defaults to `false`.
|
|
2062
|
+
*/
|
|
2063
|
+
caseSensitive?: IndexRouteObject["caseSensitive"];
|
|
2064
|
+
/**
|
|
2065
|
+
* The path pattern to match. If unspecified or empty, then this becomes a
|
|
2066
|
+
* layout route.
|
|
2067
|
+
*/
|
|
2068
|
+
path?: IndexRouteObject["path"];
|
|
2069
|
+
/**
|
|
2070
|
+
* The unique identifier for this route (for use with {@link DataRouter}s)
|
|
2071
|
+
*/
|
|
2072
|
+
id?: IndexRouteObject["id"];
|
|
2073
|
+
/**
|
|
2074
|
+
* A function that returns a promise that resolves to the route object.
|
|
2075
|
+
* Used for code-splitting routes.
|
|
2076
|
+
* See [`lazy`](../../start/data/route-object#lazy).
|
|
2077
|
+
*/
|
|
2078
|
+
lazy?: LazyRouteFunction<IndexRouteObject>;
|
|
2079
|
+
/**
|
|
2080
|
+
* The route loader.
|
|
2081
|
+
* See [`loader`](../../start/data/route-object#loader).
|
|
2082
|
+
*/
|
|
2083
|
+
loader?: IndexRouteObject["loader"];
|
|
2084
|
+
/**
|
|
2085
|
+
* The route action.
|
|
2086
|
+
* See [`action`](../../start/data/route-object#action).
|
|
2087
|
+
*/
|
|
2088
|
+
action?: IndexRouteObject["action"];
|
|
2089
|
+
hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
|
|
2090
|
+
/**
|
|
2091
|
+
* The route shouldRevalidate function.
|
|
2092
|
+
* See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
|
|
2093
|
+
*/
|
|
2094
|
+
shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
|
|
2095
|
+
/**
|
|
2096
|
+
* The route handle.
|
|
2097
|
+
*/
|
|
2098
|
+
handle?: IndexRouteObject["handle"];
|
|
2099
|
+
/**
|
|
2100
|
+
* Whether this is an index route.
|
|
2101
|
+
*/
|
|
2102
|
+
index: true;
|
|
2103
|
+
/**
|
|
2104
|
+
* Child Route components
|
|
2105
|
+
*/
|
|
2106
|
+
children?: undefined;
|
|
2107
|
+
/**
|
|
2108
|
+
* The React element to render when this Route matches.
|
|
2109
|
+
* Mutually exclusive with `Component`.
|
|
2110
|
+
*/
|
|
2111
|
+
element?: React.ReactNode | null;
|
|
2112
|
+
/**
|
|
2113
|
+
* The React element to render while this router is loading data.
|
|
2114
|
+
* Mutually exclusive with `HydrateFallback`.
|
|
2115
|
+
*/
|
|
2116
|
+
hydrateFallbackElement?: React.ReactNode | null;
|
|
2117
|
+
/**
|
|
2118
|
+
* The React element to render at this route if an error occurs.
|
|
2119
|
+
* Mutually exclusive with `ErrorBoundary`.
|
|
2120
|
+
*/
|
|
2121
|
+
errorElement?: React.ReactNode | null;
|
|
2122
|
+
/**
|
|
2123
|
+
* The React Component to render when this route matches.
|
|
2124
|
+
* Mutually exclusive with `element`.
|
|
2125
|
+
*/
|
|
2126
|
+
Component?: React.ComponentType | null;
|
|
2127
|
+
/**
|
|
2128
|
+
* The React Component to render while this router is loading data.
|
|
2129
|
+
* Mutually exclusive with `hydrateFallbackElement`.
|
|
2130
|
+
*/
|
|
2131
|
+
HydrateFallback?: React.ComponentType | null;
|
|
2132
|
+
/**
|
|
2133
|
+
* The React Component to render at this route if an error occurs.
|
|
2134
|
+
* Mutually exclusive with `errorElement`.
|
|
2135
|
+
*/
|
|
2136
|
+
ErrorBoundary?: React.ComponentType | null;
|
|
2137
|
+
}
|
|
2138
|
+
type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
|
|
2139
|
+
/**
|
|
2140
|
+
* Configures an element to render when a pattern matches the current location.
|
|
2141
|
+
* It must be rendered within a {@link Routes} element. Note that these routes
|
|
2142
|
+
* do not participate in data loading, actions, code splitting, or any other
|
|
2143
|
+
* route module features.
|
|
2144
|
+
*
|
|
2145
|
+
* @example
|
|
2146
|
+
* // Usually used in a declarative router
|
|
2147
|
+
* function App() {
|
|
2148
|
+
* return (
|
|
2149
|
+
* <BrowserRouter>
|
|
2150
|
+
* <Routes>
|
|
2151
|
+
* <Route index element={<StepOne />} />
|
|
2152
|
+
* <Route path="step-2" element={<StepTwo />} />
|
|
2153
|
+
* <Route path="step-3" element={<StepThree />} />
|
|
2154
|
+
* </Routes>
|
|
2155
|
+
* </BrowserRouter>
|
|
2156
|
+
* );
|
|
2157
|
+
* }
|
|
2158
|
+
*
|
|
2159
|
+
* // But can be used with a data router as well if you prefer the JSX notation
|
|
2160
|
+
* const routes = createRoutesFromElements(
|
|
2161
|
+
* <>
|
|
2162
|
+
* <Route index loader={step1Loader} Component={StepOne} />
|
|
2163
|
+
* <Route path="step-2" loader={step2Loader} Component={StepTwo} />
|
|
2164
|
+
* <Route path="step-3" loader={step3Loader} Component={StepThree} />
|
|
2165
|
+
* </>
|
|
2166
|
+
* );
|
|
2167
|
+
*
|
|
2168
|
+
* const router = createBrowserRouter(routes);
|
|
2169
|
+
*
|
|
2170
|
+
* function App() {
|
|
2171
|
+
* return <RouterProvider router={router} />;
|
|
2172
|
+
* }
|
|
2173
|
+
*
|
|
2174
|
+
* @public
|
|
2175
|
+
* @category Components
|
|
2176
|
+
* @param props Props
|
|
2177
|
+
* @param {PathRouteProps.action} props.action n/a
|
|
2178
|
+
* @param {PathRouteProps.caseSensitive} props.caseSensitive n/a
|
|
2179
|
+
* @param {PathRouteProps.Component} props.Component n/a
|
|
2180
|
+
* @param {PathRouteProps.children} props.children n/a
|
|
2181
|
+
* @param {PathRouteProps.element} props.element n/a
|
|
2182
|
+
* @param {PathRouteProps.ErrorBoundary} props.ErrorBoundary n/a
|
|
2183
|
+
* @param {PathRouteProps.errorElement} props.errorElement n/a
|
|
2184
|
+
* @param {PathRouteProps.handle} props.handle n/a
|
|
2185
|
+
* @param {PathRouteProps.HydrateFallback} props.HydrateFallback n/a
|
|
2186
|
+
* @param {PathRouteProps.hydrateFallbackElement} props.hydrateFallbackElement n/a
|
|
2187
|
+
* @param {PathRouteProps.id} props.id n/a
|
|
2188
|
+
* @param {PathRouteProps.index} props.index n/a
|
|
2189
|
+
* @param {PathRouteProps.lazy} props.lazy n/a
|
|
2190
|
+
* @param {PathRouteProps.loader} props.loader n/a
|
|
2191
|
+
* @param {PathRouteProps.path} props.path n/a
|
|
2192
|
+
* @param {PathRouteProps.shouldRevalidate} props.shouldRevalidate n/a
|
|
2193
|
+
* @returns {void}
|
|
2194
|
+
*/
|
|
2195
|
+
declare function Route(props: RouteProps): React.ReactElement | null;
|
|
2196
|
+
/**
|
|
2197
|
+
* @category Types
|
|
2198
|
+
*/
|
|
2199
|
+
interface RouterProps {
|
|
2200
|
+
/**
|
|
2201
|
+
* The base path for the application. This is prepended to all locations
|
|
2202
|
+
*/
|
|
2203
|
+
basename?: string;
|
|
2204
|
+
/**
|
|
2205
|
+
* Nested {@link Route} elements describing the route tree
|
|
2206
|
+
*/
|
|
2207
|
+
children?: React.ReactNode;
|
|
2208
|
+
/**
|
|
2209
|
+
* The location to match against. Defaults to the current location.
|
|
2210
|
+
* This can be a string or a {@link Location} object.
|
|
2211
|
+
*/
|
|
2212
|
+
location: Partial<Location> | string;
|
|
2213
|
+
/**
|
|
2214
|
+
* The type of navigation that triggered this `location` change.
|
|
2215
|
+
* Defaults to {@link NavigationType.Pop}.
|
|
2216
|
+
*/
|
|
2217
|
+
navigationType?: Action;
|
|
2218
|
+
/**
|
|
2219
|
+
* The navigator to use for navigation. This is usually a history object
|
|
2220
|
+
* or a custom navigator that implements the {@link Navigator} interface.
|
|
2221
|
+
*/
|
|
2222
|
+
navigator: Navigator;
|
|
2223
|
+
/**
|
|
2224
|
+
* Whether this router is static or not (used for SSR). If `true`, the router
|
|
2225
|
+
* will not be reactive to location changes.
|
|
2226
|
+
*/
|
|
2227
|
+
static?: boolean;
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Provides location context for the rest of the app.
|
|
2231
|
+
*
|
|
2232
|
+
* Note: You usually won't render a `<Router>` directly. Instead, you'll render a
|
|
2233
|
+
* router that is more specific to your environment such as a {@link BrowserRouter}
|
|
2234
|
+
* in web browsers or a {@link ServerRouter} for server rendering.
|
|
2235
|
+
*
|
|
2236
|
+
* @public
|
|
2237
|
+
* @category Declarative Routers
|
|
2238
|
+
* @mode declarative
|
|
2239
|
+
* @param props Props
|
|
2240
|
+
* @param {RouterProps.basename} props.basename n/a
|
|
2241
|
+
* @param {RouterProps.children} props.children n/a
|
|
2242
|
+
* @param {RouterProps.location} props.location n/a
|
|
2243
|
+
* @param {RouterProps.navigationType} props.navigationType n/a
|
|
2244
|
+
* @param {RouterProps.navigator} props.navigator n/a
|
|
2245
|
+
* @param {RouterProps.static} props.static n/a
|
|
2246
|
+
* @returns React element for the rendered router or `null` if the location does
|
|
2247
|
+
* not match the {@link props.basename}
|
|
2248
|
+
*/
|
|
2249
|
+
declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
|
|
2250
|
+
/**
|
|
2251
|
+
* @category Types
|
|
2252
|
+
*/
|
|
2253
|
+
interface RoutesProps {
|
|
2254
|
+
/**
|
|
2255
|
+
* Nested {@link Route} elements
|
|
2256
|
+
*/
|
|
2257
|
+
children?: React.ReactNode;
|
|
2258
|
+
/**
|
|
2259
|
+
* The {@link Location} to match against. Defaults to the current location.
|
|
2260
|
+
*/
|
|
2261
|
+
location?: Partial<Location> | string;
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Renders a branch of {@link Route | `<Route>`s} that best matches the current
|
|
2265
|
+
* location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
|
|
2266
|
+
* [`action`](../../start/framework/route-module#action), code splitting, or
|
|
2267
|
+
* any other [route module](../../start/framework/route-module) features.
|
|
2268
|
+
*
|
|
2269
|
+
* @example
|
|
2270
|
+
* import { Route, Routes } from "react-router";
|
|
2271
|
+
*
|
|
2272
|
+
* <Routes>
|
|
2273
|
+
* <Route index element={<StepOne />} />
|
|
2274
|
+
* <Route path="step-2" element={<StepTwo />} />
|
|
2275
|
+
* <Route path="step-3" element={<StepThree />}>
|
|
2276
|
+
* </Routes>
|
|
2277
|
+
*
|
|
2278
|
+
* @public
|
|
2279
|
+
* @category Components
|
|
2280
|
+
* @param props Props
|
|
2281
|
+
* @param {RoutesProps.children} props.children n/a
|
|
2282
|
+
* @param {RoutesProps.location} props.location n/a
|
|
2283
|
+
* @returns React element for the rendered routes or `null` if no route matches
|
|
2284
|
+
*/
|
|
2285
|
+
declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
|
|
2286
|
+
interface AwaitResolveRenderFunction<Resolve = any> {
|
|
2287
|
+
(data: Awaited<Resolve>): React.ReactNode;
|
|
2288
|
+
}
|
|
2289
|
+
/**
|
|
2290
|
+
* @category Types
|
|
2291
|
+
*/
|
|
2292
|
+
interface AwaitProps<Resolve> {
|
|
2293
|
+
/**
|
|
2294
|
+
* When using a function, the resolved value is provided as the parameter.
|
|
2295
|
+
*
|
|
2296
|
+
* ```tsx [2]
|
|
2297
|
+
* <Await resolve={reviewsPromise}>
|
|
2298
|
+
* {(resolvedReviews) => <Reviews items={resolvedReviews} />}
|
|
2299
|
+
* </Await>
|
|
2300
|
+
* ```
|
|
2301
|
+
*
|
|
2302
|
+
* When using React elements, {@link useAsyncValue} will provide the
|
|
2303
|
+
* resolved value:
|
|
2304
|
+
*
|
|
2305
|
+
* ```tsx [2]
|
|
2306
|
+
* <Await resolve={reviewsPromise}>
|
|
2307
|
+
* <Reviews />
|
|
2308
|
+
* </Await>
|
|
2309
|
+
*
|
|
2310
|
+
* function Reviews() {
|
|
2311
|
+
* const resolvedReviews = useAsyncValue();
|
|
2312
|
+
* return <div>...</div>;
|
|
2313
|
+
* }
|
|
2314
|
+
* ```
|
|
2315
|
+
*/
|
|
2316
|
+
children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
|
|
2317
|
+
/**
|
|
2318
|
+
* The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
2319
|
+
* rejects.
|
|
2320
|
+
*
|
|
2321
|
+
* ```tsx
|
|
2322
|
+
* <Await
|
|
2323
|
+
* errorElement={<div>Oops</div>}
|
|
2324
|
+
* resolve={reviewsPromise}
|
|
2325
|
+
* >
|
|
2326
|
+
* <Reviews />
|
|
2327
|
+
* </Await>
|
|
2328
|
+
* ```
|
|
2329
|
+
*
|
|
2330
|
+
* To provide a more contextual error, you can use the {@link useAsyncError} in a
|
|
2331
|
+
* child component
|
|
2332
|
+
*
|
|
2333
|
+
* ```tsx
|
|
2334
|
+
* <Await
|
|
2335
|
+
* errorElement={<ReviewsError />}
|
|
2336
|
+
* resolve={reviewsPromise}
|
|
2337
|
+
* >
|
|
2338
|
+
* <Reviews />
|
|
2339
|
+
* </Await>
|
|
2340
|
+
*
|
|
2341
|
+
* function ReviewsError() {
|
|
2342
|
+
* const error = useAsyncError();
|
|
2343
|
+
* return <div>Error loading reviews: {error.message}</div>;
|
|
2344
|
+
* }
|
|
2345
|
+
* ```
|
|
2346
|
+
*
|
|
2347
|
+
* If you do not provide an `errorElement`, the rejected value will bubble up
|
|
2348
|
+
* to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
|
|
2349
|
+
* and be accessible via the {@link useRouteError} hook.
|
|
2350
|
+
*/
|
|
2351
|
+
errorElement?: React.ReactNode;
|
|
2352
|
+
/**
|
|
2353
|
+
* Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
2354
|
+
* returned from a [`loader`](../../start/framework/route-module#loader) to be
|
|
2355
|
+
* resolved and rendered.
|
|
2356
|
+
*
|
|
2357
|
+
* ```tsx
|
|
2358
|
+
* import { Await, useLoaderData } from "react-router";
|
|
2359
|
+
*
|
|
2360
|
+
* export async function loader() {
|
|
2361
|
+
* let reviews = getReviews(); // not awaited
|
|
2362
|
+
* let book = await getBook();
|
|
2363
|
+
* return {
|
|
2364
|
+
* book,
|
|
2365
|
+
* reviews, // this is a promise
|
|
2366
|
+
* };
|
|
2367
|
+
* }
|
|
2368
|
+
*
|
|
2369
|
+
* export default function Book() {
|
|
2370
|
+
* const {
|
|
2371
|
+
* book,
|
|
2372
|
+
* reviews, // this is the same promise
|
|
2373
|
+
* } = useLoaderData();
|
|
2374
|
+
*
|
|
2375
|
+
* return (
|
|
2376
|
+
* <div>
|
|
2377
|
+
* <h1>{book.title}</h1>
|
|
2378
|
+
* <p>{book.description}</p>
|
|
2379
|
+
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
2380
|
+
* <Await
|
|
2381
|
+
* // and is the promise we pass to Await
|
|
2382
|
+
* resolve={reviews}
|
|
2383
|
+
* >
|
|
2384
|
+
* <Reviews />
|
|
2385
|
+
* </Await>
|
|
2386
|
+
* </React.Suspense>
|
|
2387
|
+
* </div>
|
|
2388
|
+
* );
|
|
2389
|
+
* }
|
|
2390
|
+
* ```
|
|
2391
|
+
*/
|
|
2392
|
+
resolve: Resolve;
|
|
2393
|
+
}
|
|
2394
|
+
/**
|
|
2395
|
+
* Used to render promise values with automatic error handling.
|
|
2396
|
+
*
|
|
2397
|
+
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
2398
|
+
*
|
|
2399
|
+
* @example
|
|
2400
|
+
* import { Await, useLoaderData } from "react-router";
|
|
2401
|
+
*
|
|
2402
|
+
* export async function loader() {
|
|
2403
|
+
* // not awaited
|
|
2404
|
+
* const reviews = getReviews();
|
|
2405
|
+
* // awaited (blocks the transition)
|
|
2406
|
+
* const book = await fetch("/api/book").then((res) => res.json());
|
|
2407
|
+
* return { book, reviews };
|
|
2408
|
+
* }
|
|
2409
|
+
*
|
|
2410
|
+
* function Book() {
|
|
2411
|
+
* const { book, reviews } = useLoaderData();
|
|
2412
|
+
* return (
|
|
2413
|
+
* <div>
|
|
2414
|
+
* <h1>{book.title}</h1>
|
|
2415
|
+
* <p>{book.description}</p>
|
|
2416
|
+
* <React.Suspense fallback={<ReviewsSkeleton />}>
|
|
2417
|
+
* <Await
|
|
2418
|
+
* resolve={reviews}
|
|
2419
|
+
* errorElement={
|
|
2420
|
+
* <div>Could not load reviews 😬</div>
|
|
2421
|
+
* }
|
|
2422
|
+
* children={(resolvedReviews) => (
|
|
2423
|
+
* <Reviews items={resolvedReviews} />
|
|
2424
|
+
* )}
|
|
2425
|
+
* />
|
|
2426
|
+
* </React.Suspense>
|
|
2427
|
+
* </div>
|
|
2428
|
+
* );
|
|
2429
|
+
* }
|
|
2430
|
+
*
|
|
2431
|
+
* @public
|
|
2432
|
+
* @category Components
|
|
2433
|
+
* @mode framework
|
|
2434
|
+
* @mode data
|
|
2435
|
+
* @param props Props
|
|
2436
|
+
* @param {AwaitProps.children} props.children n/a
|
|
2437
|
+
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
2438
|
+
* @param {AwaitProps.resolve} props.resolve n/a
|
|
2439
|
+
* @returns React element for the rendered awaited value
|
|
2440
|
+
*/
|
|
2441
|
+
declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
|
|
2442
|
+
/**
|
|
2443
|
+
* Creates a route config from a React "children" object, which is usually
|
|
2444
|
+
* either a `<Route>` element or an array of them. Used internally by
|
|
2445
|
+
* `<Routes>` to create a route config from its children.
|
|
2446
|
+
*
|
|
2447
|
+
* @category Utils
|
|
2448
|
+
* @mode data
|
|
2449
|
+
* @param children The React children to convert into a route config
|
|
2450
|
+
* @param parentPath The path of the parent route, used to generate unique IDs.
|
|
2451
|
+
* @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
|
|
2452
|
+
*/
|
|
2453
|
+
declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
|
|
2454
|
+
/**
|
|
2455
|
+
* Create route objects from JSX elements instead of arrays of objects.
|
|
2456
|
+
*
|
|
2457
|
+
* @example
|
|
2458
|
+
* const routes = createRoutesFromElements(
|
|
2459
|
+
* <>
|
|
2460
|
+
* <Route index loader={step1Loader} Component={StepOne} />
|
|
2461
|
+
* <Route path="step-2" loader={step2Loader} Component={StepTwo} />
|
|
2462
|
+
* <Route path="step-3" loader={step3Loader} Component={StepThree} />
|
|
2463
|
+
* </>
|
|
2464
|
+
* );
|
|
2465
|
+
*
|
|
2466
|
+
* const router = createBrowserRouter(routes);
|
|
2467
|
+
*
|
|
2468
|
+
* function App() {
|
|
2469
|
+
* return <RouterProvider router={router} />;
|
|
2470
|
+
* }
|
|
2471
|
+
*
|
|
2472
|
+
* @name createRoutesFromElements
|
|
2473
|
+
* @public
|
|
2474
|
+
* @category Utils
|
|
2475
|
+
* @mode data
|
|
2476
|
+
* @param children The React children to convert into a route config
|
|
2477
|
+
* @param parentPath The path of the parent route, used to generate unique IDs.
|
|
2478
|
+
* This is used for internal recursion and is not intended to be used by the
|
|
2479
|
+
* application developer.
|
|
2480
|
+
* @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
|
|
2481
|
+
*/
|
|
2482
|
+
declare const createRoutesFromElements: typeof createRoutesFromChildren;
|
|
2483
|
+
/**
|
|
2484
|
+
* Renders the result of {@link matchRoutes} into a React element.
|
|
2485
|
+
*
|
|
2486
|
+
* @public
|
|
2487
|
+
* @category Utils
|
|
2488
|
+
* @param matches The array of {@link RouteMatch | route matches} to render
|
|
2489
|
+
* @returns A React element that renders the matched routes or `null` if no matches
|
|
2490
|
+
*/
|
|
2491
|
+
declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
|
|
2492
|
+
declare function useRouteComponentProps(): {
|
|
2493
|
+
params: Readonly<Params<string>>;
|
|
2494
|
+
loaderData: any;
|
|
2495
|
+
actionData: any;
|
|
2496
|
+
matches: UIMatch<unknown, unknown>[];
|
|
2497
|
+
};
|
|
2498
|
+
type RouteComponentProps = ReturnType<typeof useRouteComponentProps>;
|
|
2499
|
+
type RouteComponentType = React.ComponentType<RouteComponentProps>;
|
|
2500
|
+
declare function WithComponentProps({ children, }: {
|
|
2501
|
+
children: React.ReactElement;
|
|
2502
|
+
}): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
2503
|
+
declare function withComponentProps(Component: RouteComponentType): () => React.ReactElement<{
|
|
2504
|
+
params: Readonly<Params<string>>;
|
|
2505
|
+
loaderData: any;
|
|
2506
|
+
actionData: any;
|
|
2507
|
+
matches: UIMatch<unknown, unknown>[];
|
|
2508
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
2509
|
+
declare function useHydrateFallbackProps(): {
|
|
2510
|
+
params: Readonly<Params<string>>;
|
|
2511
|
+
loaderData: any;
|
|
2512
|
+
actionData: any;
|
|
2513
|
+
};
|
|
2514
|
+
type HydrateFallbackProps = ReturnType<typeof useHydrateFallbackProps>;
|
|
2515
|
+
type HydrateFallbackType = React.ComponentType<HydrateFallbackProps>;
|
|
2516
|
+
declare function WithHydrateFallbackProps({ children, }: {
|
|
2517
|
+
children: React.ReactElement;
|
|
2518
|
+
}): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
2519
|
+
declare function withHydrateFallbackProps(HydrateFallback: HydrateFallbackType): () => React.ReactElement<{
|
|
2520
|
+
params: Readonly<Params<string>>;
|
|
2521
|
+
loaderData: any;
|
|
2522
|
+
actionData: any;
|
|
2523
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
2524
|
+
declare function useErrorBoundaryProps(): {
|
|
2525
|
+
params: Readonly<Params<string>>;
|
|
2526
|
+
loaderData: any;
|
|
2527
|
+
actionData: any;
|
|
2528
|
+
error: unknown;
|
|
2529
|
+
};
|
|
2530
|
+
type ErrorBoundaryProps = ReturnType<typeof useErrorBoundaryProps>;
|
|
2531
|
+
type ErrorBoundaryType = React.ComponentType<ErrorBoundaryProps>;
|
|
2532
|
+
declare function WithErrorBoundaryProps({ children, }: {
|
|
2533
|
+
children: React.ReactElement;
|
|
2534
|
+
}): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
2535
|
+
declare function withErrorBoundaryProps(ErrorBoundary: ErrorBoundaryType): () => React.ReactElement<{
|
|
2536
|
+
params: Readonly<Params<string>>;
|
|
2537
|
+
loaderData: any;
|
|
2538
|
+
actionData: any;
|
|
2539
|
+
error: unknown;
|
|
2540
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
2541
|
+
|
|
1704
2542
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
1705
2543
|
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
1706
2544
|
interface HtmlLinkProps {
|
|
@@ -1865,7 +2703,7 @@ type unstable_SerializesTo<T> = {
|
|
|
1865
2703
|
unstable__ReactRouter_SerializesTo: [T];
|
|
1866
2704
|
};
|
|
1867
2705
|
|
|
1868
|
-
type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
|
|
2706
|
+
type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
|
|
1869
2707
|
[K in keyof T]: Serialize<T[K]>;
|
|
1870
2708
|
} : undefined;
|
|
1871
2709
|
type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
|
@@ -1972,7 +2810,7 @@ interface RouteModules {
|
|
|
1972
2810
|
interface RouteModule {
|
|
1973
2811
|
clientAction?: ClientActionFunction;
|
|
1974
2812
|
clientLoader?: ClientLoaderFunction;
|
|
1975
|
-
unstable_clientMiddleware?: unstable_MiddlewareFunction<
|
|
2813
|
+
unstable_clientMiddleware?: unstable_MiddlewareFunction<Record<string, DataStrategyResult>>[];
|
|
1976
2814
|
ErrorBoundary?: ErrorBoundaryComponent;
|
|
1977
2815
|
HydrateFallback?: HydrateFallbackComponent;
|
|
1978
2816
|
Layout?: LayoutComponent;
|
|
@@ -2170,4 +3008,4 @@ type RouteComponent = ComponentType<{}>;
|
|
|
2170
3008
|
*/
|
|
2171
3009
|
type RouteHandle = unknown;
|
|
2172
3010
|
|
|
2173
|
-
export { type
|
|
3011
|
+
export { type PatchRoutesOnNavigationFunction as $, Action as A, type BlockerFunction as B, type ClientDataFunctionArgs as C, type DataStrategyResult as D, type ErrorBoundaryType as E, type Func as F, type GetLoaderData as G, type HydrationState as H, type InitialEntry as I, type AppLoadContext as J, unstable_RouterContextProvider as K, type LinkDescriptor as L, type MetaDescriptor as M, type Normalize as N, type MiddlewareEnabled as O, type Pretty as P, type Equal as Q, type RouteModule$1 as R, type ServerDataFunctionArgs as S, type To as T, type UIMatch as U, type ClientActionFunction as V, type ClientLoaderFunction as W, type HeadersFunction as X, type ShouldRevalidateFunction as Y, type RouterInit as Z, type RouterState as _, type Location as a, Router as a$, type DataRouteObject as a0, type StaticHandler as a1, type GetScrollPositionFunction as a2, type GetScrollRestorationKeyFunction as a3, type StaticHandlerContext as a4, type Fetcher as a5, type NavigationStates as a6, type RouterSubscriber as a7, type RouterNavigateOptions as a8, type RouterFetchOptions as a9, matchRoutes as aA, redirect as aB, redirectDocument as aC, replace as aD, resolvePath as aE, type DataRouteMatch as aF, type Navigator as aG, type PatchRoutesOnNavigationFunctionArgs as aH, type RouteMatch as aI, type AwaitProps as aJ, type IndexRouteProps as aK, type unstable_ClientOnErrorFunction as aL, type LayoutRouteProps as aM, type MemoryRouterOpts as aN, type MemoryRouterProps as aO, type NavigateProps as aP, type OutletProps as aQ, type PathRouteProps as aR, type RouteProps as aS, type RouterProps as aT, type RouterProviderProps as aU, type RoutesProps as aV, Await as aW, MemoryRouter as aX, Navigate as aY, Outlet as aZ, Route as a_, type RevalidationState as aa, type ActionFunctionArgs as ab, type DataStrategyFunctionArgs as ac, type DataStrategyMatch as ad, DataWithResponseInit as ae, type ErrorResponse as af, type FormEncType as ag, type FormMethod as ah, type HTMLFormMethod as ai, type LazyRouteFunction as aj, type LoaderFunctionArgs as ak, type unstable_MiddlewareFunction as al, type PathParam as am, type RedirectFunction as an, type unstable_RouterContext as ao, type ShouldRevalidateFunctionArgs as ap, unstable_createContext as aq, createPath as ar, parsePath as as, IDLE_NAVIGATION as at, IDLE_FETCHER as au, IDLE_BLOCKER as av, data as aw, generatePath as ax, isRouteErrorResponse as ay, matchPath as az, type ServerDataFrom as b, RouterProvider as b0, Routes as b1, createMemoryRouter as b2, createRoutesFromChildren as b3, createRoutesFromElements as b4, renderMatches as b5, type ClientActionFunctionArgs as b6, type ClientLoaderFunctionArgs as b7, type HeadersArgs as b8, type MetaArgs as b9, type FutureConfig as bA, type CreateStaticHandlerOptions as bB, type PageLinkDescriptor as ba, type HtmlLinkDescriptor as bb, type Future as bc, type unstable_SerializesTo as bd, createBrowserHistory as be, invariant as bf, createRouter as bg, ErrorResponseImpl as bh, DataRouterContext as bi, DataRouterStateContext as bj, FetchersContext as bk, LocationContext as bl, NavigationContext as bm, RouteContext as bn, ViewTransitionContext as bo, hydrationRouteProperties as bp, mapRouteProperties as bq, WithComponentProps as br, withComponentProps as bs, WithHydrateFallbackProps as bt, withHydrateFallbackProps as bu, WithErrorBoundaryProps as bv, withErrorBoundaryProps as bw, type RouteManifest as bx, type ServerRouteModule as by, type History as bz, type GetActionData as c, type Router$1 as d, type RouteModules as e, type DataStrategyFunction as f, type NavigateOptions as g, type Blocker as h, type SerializeFrom as i, type RelativeRoutingType as j, type ParamParseKey as k, type Path as l, type PathPattern as m, type PathMatch as n, type Navigation as o, type Params as p, type RouteObject as q, type IndexRouteObject as r, type RouteComponentType as s, type HydrateFallbackType as t, type unstable_MiddlewareNextFunction as u, type LoaderFunction as v, type ActionFunction as w, type MetaFunction as x, type LinksFunction as y, type NonIndexRouteObject as z };
|