Skip to content

Commit b4769d8

Browse files
committed
Stabilize unstable_patchRoutesOnNavigation
1 parent 6f6924b commit b4769d8

File tree

7 files changed

+75
-75
lines changed

7 files changed

+75
-75
lines changed

docs/routers/create-browser-router.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function createBrowserRouter(
5252
future?: FutureConfig;
5353
hydrationData?: HydrationState;
5454
dataStrategy?: DataStrategyFunction;
55-
unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction;
55+
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
5656
window?: Window;
5757
}
5858
): RemixRouter;
@@ -384,7 +384,7 @@ let router = createBrowserRouter(routes, {
384384
});
385385
```
386386

387-
## `opts.unstable_patchRoutesOnNavigation`
387+
## `opts.patchRoutesOnNavigation`
388388

389389
<docs-warning>This API is marked "unstable" so it is subject to breaking API changes in minor releases</docs-warning>
390390

@@ -394,12 +394,12 @@ To combat this, we introduced [`route.lazy`][route-lazy] in [v6.9.0][6-9-0] whic
394394

395395
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.
396396

397-
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.
397+
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.
398398

399399
### Type Declaration
400400

401401
```ts
402-
export interface unstable_PatchRoutesOnNavigationFunction {
402+
export interface PatchRoutesOnNavigationFunction {
403403
(opts: {
404404
path: string;
405405
matches: RouteMatch[];
@@ -413,7 +413,7 @@ export interface unstable_PatchRoutesOnNavigationFunction {
413413

414414
### Overview
415415

416-
`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.
416+
`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.
417417

418418
**Patching children into an existing route**
419419

@@ -427,7 +427,7 @@ const router = createBrowserRouter(
427427
},
428428
],
429429
{
430-
async unstable_patchRoutesOnNavigation({
430+
async patchRoutesOnNavigation({
431431
path,
432432
patch,
433433
}) {
@@ -458,7 +458,7 @@ const router = createBrowserRouter(
458458
},
459459
],
460460
{
461-
async unstable_patchRoutesOnNavigation({
461+
async patchRoutesOnNavigation({
462462
path,
463463
patch,
464464
}) {
@@ -486,7 +486,7 @@ let router = createBrowserRouter(
486486
},
487487
],
488488
{
489-
async unstable_patchRoutesOnNavigation({
489+
async patchRoutesOnNavigation({
490490
path,
491491
patch,
492492
}) {
@@ -544,7 +544,7 @@ let router = createBrowserRouter(
544544
},
545545
],
546546
{
547-
async unstable_patchRoutesOnNavigation({
547+
async patchRoutesOnNavigation({
548548
matches,
549549
patch,
550550
}) {

packages/react-router-dom/__tests__/partial-hydration-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("v7_partialHydration", () => {
6969
future: {
7070
v7_partialHydration: true,
7171
},
72-
unstable_patchRoutesOnNavigation({ path, patch }) {
72+
patchRoutesOnNavigation({ path, patch }) {
7373
if (path === "/parent/child") {
7474
patch("parent", [
7575
{
@@ -157,7 +157,7 @@ describe("v7_partialHydration", () => {
157157
future: {
158158
v7_partialHydration: true,
159159
},
160-
unstable_patchRoutesOnNavigation({ path, patch }) {
160+
patchRoutesOnNavigation({ path, patch }) {
161161
if (path === "/parent/child") {
162162
patch("parent", [
163163
{

packages/react-router-dom/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
RouterProps,
1717
RouterProviderProps,
1818
To,
19-
unstable_PatchRoutesOnNavigationFunction,
19+
PatchRoutesOnNavigationFunction,
2020
} from "react-router";
2121
import {
2222
Router,
@@ -153,7 +153,7 @@ export type {
153153
To,
154154
UIMatch,
155155
unstable_HandlerResult,
156-
unstable_PatchRoutesOnNavigationFunction,
156+
PatchRoutesOnNavigationFunction,
157157
} from "react-router";
158158
export {
159159
AbortedDeferredError,
@@ -261,7 +261,7 @@ interface DOMRouterOpts {
261261
future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
262262
hydrationData?: HydrationState;
263263
dataStrategy?: DataStrategyFunction;
264-
unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction;
264+
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
265265
window?: Window;
266266
}
267267

@@ -280,7 +280,7 @@ export function createBrowserRouter(
280280
routes,
281281
mapRouteProperties,
282282
dataStrategy: opts?.dataStrategy,
283-
unstable_patchRoutesOnNavigation: opts?.unstable_patchRoutesOnNavigation,
283+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
284284
window: opts?.window,
285285
}).initialize();
286286
}
@@ -300,7 +300,7 @@ export function createHashRouter(
300300
routes,
301301
mapRouteProperties,
302302
dataStrategy: opts?.dataStrategy,
303-
unstable_patchRoutesOnNavigation: opts?.unstable_patchRoutesOnNavigation,
303+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
304304
window: opts?.window,
305305
}).initialize();
306306
}

packages/react-router/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import type {
3232
To,
3333
UIMatch,
3434
unstable_HandlerResult,
35-
unstable_AgnosticPatchRoutesOnNavigationFunction,
35+
AgnosticPatchRoutesOnNavigationFunction,
3636
} from "@remix-run/router";
3737
import {
3838
AbortedDeferredError,
@@ -291,8 +291,8 @@ function mapRouteProperties(route: RouteObject) {
291291
return updates;
292292
}
293293

294-
export interface unstable_PatchRoutesOnNavigationFunction
295-
extends unstable_AgnosticPatchRoutesOnNavigationFunction<RouteMatch> {}
294+
export interface PatchRoutesOnNavigationFunction
295+
extends AgnosticPatchRoutesOnNavigationFunction<RouteMatch> {}
296296

297297
export function createMemoryRouter(
298298
routes: RouteObject[],
@@ -303,7 +303,7 @@ export function createMemoryRouter(
303303
initialEntries?: InitialEntry[];
304304
initialIndex?: number;
305305
dataStrategy?: DataStrategyFunction;
306-
unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction;
306+
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
307307
}
308308
): RemixRouter {
309309
return createRouter({
@@ -320,7 +320,7 @@ export function createMemoryRouter(
320320
routes,
321321
mapRouteProperties,
322322
dataStrategy: opts?.dataStrategy,
323-
unstable_patchRoutesOnNavigation: opts?.unstable_patchRoutesOnNavigation,
323+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
324324
}).initialize();
325325
}
326326

0 commit comments

Comments
 (0)