diff --git a/.changeset/happy-grapes-fry.md b/.changeset/happy-grapes-fry.md new file mode 100644 index 0000000000..f0e409c544 --- /dev/null +++ b/.changeset/happy-grapes-fry.md @@ -0,0 +1,7 @@ +--- +"react-router-dom": minor +"react-router": minor +"@remix-run/router": minor +--- + +Stabilize `unstable_patchRoutesOnNavigation` diff --git a/docs/routers/create-browser-router.md b/docs/routers/create-browser-router.md index a2f2cb64d9..990e2bafd5 100644 --- a/docs/routers/create-browser-router.md +++ b/docs/routers/create-browser-router.md @@ -52,7 +52,7 @@ function createBrowserRouter( future?: FutureConfig; hydrationData?: HydrationState; unstable_dataStrategy?: unstable_DataStrategyFunction; - unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction; + patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction; window?: Window; } ): RemixRouter; @@ -438,7 +438,7 @@ let router = createBrowserRouter(routes, { }); ``` -## `opts.unstable_patchRoutesOnNavigation` +## `opts.patchRoutesOnNavigation` This API is marked "unstable" so it is subject to breaking API changes in minor releases @@ -448,12 +448,12 @@ To combat this, we introduced [`route.lazy`][route-lazy] in [v6.9.0][6-9-0] whic In some cases, even this doesn't go far enough. For very large applications, providing all route definitions up front can be prohibitively expensive. Additionally, it might not even be possible to provide all route definitions up front in certain Micro-Frontend or Module-Federation architectures. -This is where `unstable_patchRoutesOnNavigation` comes in ([RFC][fog-of-war-rfc]). This API is for advanced use-cases where you are unable to provide the full route tree up-front and need a way to lazily "discover" portions of the route tree at runtime. This feature is often referred to as ["Fog of War"][fog-of-war] because similar to how video games expand the "world" as you move around - the router would be expanding its routing tree as the user navigated around the app - but would only ever end up loading portions of the tree that the user visited. +This is where `patchRoutesOnNavigation` comes in ([RFC][fog-of-war-rfc]). This API is for advanced use-cases where you are unable to provide the full route tree up-front and need a way to lazily "discover" portions of the route tree at runtime. This feature is often referred to as ["Fog of War"][fog-of-war] because similar to how video games expand the "world" as you move around - the router would be expanding its routing tree as the user navigated around the app - but would only ever end up loading portions of the tree that the user visited. ### Type Declaration ```ts -export interface unstable_PatchRoutesOnNavigationFunction { +export interface PatchRoutesOnNavigationFunction { (opts: { path: string; matches: RouteMatch[]; @@ -467,7 +467,7 @@ export interface unstable_PatchRoutesOnNavigationFunction { ### Overview -`unstable_patchRoutesOnNavigation` will be called anytime React Router is unable to match a `path`. The arguments include the `path`, any partial `matches`, and a `patch` function you can call to patch new routes into the tree at a specific location. This method is executed during the `loading` portion of the navigation for `GET` requests and during the `submitting` portion of the navigation for non-`GET` requests. +`patchRoutesOnNavigation` will be called anytime React Router is unable to match a `path`. The arguments include the `path`, any partial `matches`, and a `patch` function you can call to patch new routes into the tree at a specific location. This method is executed during the `loading` portion of the navigation for `GET` requests and during the `submitting` portion of the navigation for non-`GET` requests. **Patching children into an existing route** @@ -481,7 +481,7 @@ const router = createBrowserRouter( }, ], { - async unstable_patchRoutesOnNavigation({ + async patchRoutesOnNavigation({ path, patch, }) { @@ -512,7 +512,7 @@ const router = createBrowserRouter( }, ], { - async unstable_patchRoutesOnNavigation({ + async patchRoutesOnNavigation({ path, patch, }) { @@ -540,7 +540,7 @@ let router = createBrowserRouter( }, ], { - async unstable_patchRoutesOnNavigation({ + async patchRoutesOnNavigation({ path, patch, }) { @@ -598,7 +598,7 @@ let router = createBrowserRouter( }, ], { - async unstable_patchRoutesOnNavigation({ + async patchRoutesOnNavigation({ matches, patch, }) { diff --git a/packages/react-router-dom/__tests__/partial-hydration-test.tsx b/packages/react-router-dom/__tests__/partial-hydration-test.tsx index 5a4eeeed34..7d66013698 100644 --- a/packages/react-router-dom/__tests__/partial-hydration-test.tsx +++ b/packages/react-router-dom/__tests__/partial-hydration-test.tsx @@ -69,7 +69,7 @@ describe("v7_partialHydration", () => { future: { v7_partialHydration: true, }, - unstable_patchRoutesOnNavigation({ path, patch }) { + patchRoutesOnNavigation({ path, patch }) { if (path === "/parent/child") { patch("parent", [ { @@ -157,7 +157,7 @@ describe("v7_partialHydration", () => { future: { v7_partialHydration: true, }, - unstable_patchRoutesOnNavigation({ path, patch }) { + patchRoutesOnNavigation({ path, patch }) { if (path === "/parent/child") { patch("parent", [ { diff --git a/packages/react-router-dom/index.tsx b/packages/react-router-dom/index.tsx index 5edf5889b2..1532fe6206 100644 --- a/packages/react-router-dom/index.tsx +++ b/packages/react-router-dom/index.tsx @@ -17,7 +17,7 @@ import type { RouterProviderProps, To, unstable_DataStrategyFunction, - unstable_PatchRoutesOnNavigationFunction, + PatchRoutesOnNavigationFunction, } from "react-router"; import { Router, @@ -151,7 +151,7 @@ export type { ShouldRevalidateFunctionArgs, To, UIMatch, - unstable_PatchRoutesOnNavigationFunction, + PatchRoutesOnNavigationFunction, } from "react-router"; export { AbortedDeferredError, @@ -259,7 +259,7 @@ interface DOMRouterOpts { future?: Partial>; hydrationData?: HydrationState; unstable_dataStrategy?: unstable_DataStrategyFunction; - unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction; + patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction; window?: Window; } @@ -278,7 +278,7 @@ export function createBrowserRouter( routes, mapRouteProperties, unstable_dataStrategy: opts?.unstable_dataStrategy, - unstable_patchRoutesOnNavigation: opts?.unstable_patchRoutesOnNavigation, + patchRoutesOnNavigation: opts?.patchRoutesOnNavigation, window: opts?.window, }).initialize(); } @@ -298,7 +298,7 @@ export function createHashRouter( routes, mapRouteProperties, unstable_dataStrategy: opts?.unstable_dataStrategy, - unstable_patchRoutesOnNavigation: opts?.unstable_patchRoutesOnNavigation, + patchRoutesOnNavigation: opts?.patchRoutesOnNavigation, window: opts?.window, }).initialize(); } diff --git a/packages/react-router/index.ts b/packages/react-router/index.ts index 56a7cadc19..aef4408dfd 100644 --- a/packages/react-router/index.ts +++ b/packages/react-router/index.ts @@ -32,7 +32,7 @@ import type { ShouldRevalidateFunctionArgs, To, UIMatch, - unstable_AgnosticPatchRoutesOnNavigationFunction, + AgnosticPatchRoutesOnNavigationFunction, } from "@remix-run/router"; import { AbortedDeferredError, @@ -291,8 +291,8 @@ function mapRouteProperties(route: RouteObject) { return updates; } -export interface unstable_PatchRoutesOnNavigationFunction - extends unstable_AgnosticPatchRoutesOnNavigationFunction {} +export interface PatchRoutesOnNavigationFunction + extends AgnosticPatchRoutesOnNavigationFunction {} export function createMemoryRouter( routes: RouteObject[], @@ -303,7 +303,7 @@ export function createMemoryRouter( initialEntries?: InitialEntry[]; initialIndex?: number; unstable_dataStrategy?: unstable_DataStrategyFunction; - unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction; + patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction; } ): RemixRouter { return createRouter({ @@ -320,7 +320,7 @@ export function createMemoryRouter( routes, mapRouteProperties, unstable_dataStrategy: opts?.unstable_dataStrategy, - unstable_patchRoutesOnNavigation: opts?.unstable_patchRoutesOnNavigation, + patchRoutesOnNavigation: opts?.patchRoutesOnNavigation, }).initialize(); } diff --git a/packages/router/__tests__/lazy-discovery-test.ts b/packages/router/__tests__/lazy-discovery-test.ts index 3600b3af12..0fd61d3ca1 100644 --- a/packages/router/__tests__/lazy-discovery-test.ts +++ b/packages/router/__tests__/lazy-discovery-test.ts @@ -33,7 +33,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { loader: () => loaderDfd.promise, }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -89,7 +89,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ patch, matches }) { + async patchRoutesOnNavigation({ patch, matches }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -145,7 +145,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { loader: () => loaderDfd.promise, }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -219,7 +219,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ patch, matches }) { + async patchRoutesOnNavigation({ patch, matches }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -283,7 +283,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ path, matches, patch }) { + async patchRoutesOnNavigation({ path, matches, patch }) { let routeId = last(matches).route.id; calls.push([path, routeId]); patch("a", await aDfd.promise); @@ -338,7 +338,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ path, matches, patch }) { + async patchRoutesOnNavigation({ path, matches, patch }) { let routeId = last(matches).route.id; if (!path) { return; @@ -441,7 +441,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { }, }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { let leafRoute = last(matches).route; patch(leafRoute.id, await leafRoute.handle.loadChildren?.()); }, @@ -471,7 +471,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -519,7 +519,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "/:slug", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { await tick(); patch(null, [ { @@ -547,7 +547,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "/product/:slug", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { await tick(); patch(null, [ { @@ -581,7 +581,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { ], }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { await tick(); patch("product", [ { @@ -612,7 +612,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "/:slug", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); }, }); @@ -638,7 +638,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -668,7 +668,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "/splat/*", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); patch(null, [ { @@ -702,7 +702,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { ], }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { await tick(); patch("product", [ { @@ -737,7 +737,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -755,7 +755,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { expect(router.state.matches.map((m) => m.route.id)).toEqual(["splat"]); }); - it("recurses unstable_patchRoutesOnNavigation until a match is found", async () => { + it("recurses patchRoutesOnNavigation until a match is found", async () => { let count = 0; router = createRouter({ history: createMemoryHistory(), @@ -768,7 +768,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); count++; if (last(matches).route.id === "a") { @@ -816,7 +816,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { loader: () => loaderDfd.promise, }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -872,7 +872,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { loader: () => loaderDfd.promise, }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -927,7 +927,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "*", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch(null, children); }, @@ -965,7 +965,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { splat: "SPLAT 1", }, }, - async unstable_patchRoutesOnNavigation() { + async patchRoutesOnNavigation() { throw new Error("Should not be called"); }, }); @@ -992,7 +992,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "/parent", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { patch(null, await childrenDfd.promise); }, }); @@ -1043,7 +1043,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "/:param", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { // We matched for the param but we want to patch in under root expect(matches.length).toBe(1); expect(matches[0].route.id).toBe("param"); @@ -1098,7 +1098,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "*", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { // We matched for the splat but we want to patch in at the top expect(matches.length).toBe(1); expect(matches[0].route.id).toBe("splat"); @@ -1148,7 +1148,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "/nope", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { expect(matches.length).toBe(0); let children = await childrenDfd.promise; patch(null, children); @@ -1199,7 +1199,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "parent", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -1272,7 +1272,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: ":param", }, ], - async unstable_patchRoutesOnNavigation() { + async patchRoutesOnNavigation() { count++; await tick(); // Nothing to patch - there is no better static route in this case @@ -1308,7 +1308,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "static", }, ], - async unstable_patchRoutesOnNavigation() { + async patchRoutesOnNavigation() { count++; }, }); @@ -1356,7 +1356,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: ":param", }, ], - async unstable_patchRoutesOnNavigation() { + async patchRoutesOnNavigation() { count++; // Nothing to patch - there is no better static route in this case }, @@ -1404,7 +1404,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "parent", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -1459,7 +1459,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "parent", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -1516,7 +1516,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -1569,7 +1569,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -1622,7 +1622,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -1674,7 +1674,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -1731,7 +1731,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -1788,7 +1788,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -1846,7 +1846,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { await tick(); if (shouldThrow) { shouldThrow = false; @@ -1874,7 +1874,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { 400, "Bad Request", new Error( - 'Unable to match URL "/a/b" - the `unstable_patchRoutesOnNavigation()` ' + + 'Unable to match URL "/a/b" - the `patchRoutesOnNavigation()` ' + "function threw the following error:\nError: broke!" ), true @@ -1918,7 +1918,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { await tick(); if (shouldThrow) { shouldThrow = false; @@ -1949,7 +1949,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { 400, "Bad Request", new Error( - 'Unable to match URL "/a/b" - the `unstable_patchRoutesOnNavigation()` ' + + 'Unable to match URL "/a/b" - the `patchRoutesOnNavigation()` ' + "function threw the following error:\nError: broke!" ), true @@ -2000,7 +2000,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { ], }, ], - async unstable_patchRoutesOnNavigation() { + async patchRoutesOnNavigation() { await tick(); throw new Error("broke!"); }, @@ -2024,7 +2024,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { "Bad Request", new Error( 'Unable to match URL "/parent/child/grandchild" - the ' + - "`unstable_patchRoutesOnNavigation()` function threw the following " + + "`patchRoutesOnNavigation()` function threw the following " + "error:\nError: broke!" ), true @@ -2055,7 +2055,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { ], }, ], - async unstable_patchRoutesOnNavigation() { + async patchRoutesOnNavigation() { await tick(); throw new Error("broke!"); }, @@ -2085,7 +2085,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { "Bad Request", new Error( 'Unable to match URL "/parent/child/grandchild" - the ' + - "`unstable_patchRoutesOnNavigation()` function threw the following " + + "`patchRoutesOnNavigation()` function threw the following " + "error:\nError: broke!" ), true @@ -2115,7 +2115,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "parent", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -2153,7 +2153,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ @@ -2200,7 +2200,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "parent", }, ], - async unstable_patchRoutesOnNavigation({ patch }) { + async patchRoutesOnNavigation({ patch }) { let children = await childrenDfd.promise; patch("parent", children); }, @@ -2241,7 +2241,7 @@ describe("Lazy Route Discovery (Fog of War)", () => { path: "a", }, ], - async unstable_patchRoutesOnNavigation({ matches, patch }) { + async patchRoutesOnNavigation({ matches, patch }) { await tick(); if (last(matches).route.id === "a") { patch("a", [ diff --git a/packages/router/index.ts b/packages/router/index.ts index ef32be6f50..51608bc6e5 100644 --- a/packages/router/index.ts +++ b/packages/router/index.ts @@ -23,7 +23,7 @@ export type { LoaderFunctionArgs, ParamParseKey, Params, - AgnosticPatchRoutesOnNavigationFunction as unstable_AgnosticPatchRoutesOnNavigationFunction, + AgnosticPatchRoutesOnNavigationFunction, PathMatch, PathParam, PathPattern, diff --git a/packages/router/router.ts b/packages/router/router.ts index 4691f002a8..7551725ca4 100644 --- a/packages/router/router.ts +++ b/packages/router/router.ts @@ -391,7 +391,7 @@ export interface RouterInit { future?: Partial; hydrationData?: HydrationState; window?: Window; - unstable_patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction; + patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction; unstable_dataStrategy?: DataStrategyFunction; } @@ -798,7 +798,7 @@ export function createRouter(init: RouterInit): Router { let inFlightDataRoutes: AgnosticDataRouteObject[] | undefined; let basename = init.basename || "/"; let dataStrategyImpl = init.unstable_dataStrategy || defaultDataStrategy; - let patchRoutesOnNavigationImpl = init.unstable_patchRoutesOnNavigation; + let patchRoutesOnNavigationImpl = init.patchRoutesOnNavigation; // Config driven behavior flags let future: FutureConfig = { @@ -5477,7 +5477,7 @@ function getInternalRouterError( statusText = "Bad Request"; if (type === "route-discovery") { errorMessage = - `Unable to match URL "${pathname}" - the \`unstable_patchRoutesOnNavigation()\` ` + + `Unable to match URL "${pathname}" - the \`patchRoutesOnNavigation()\` ` + `function threw the following error:\n${message}`; } else if (method && pathname && routeId) { errorMessage =