Skip to content

Commit e3b796a

Browse files
committed
Patch in 6.26.1 changes from v6 branch
1 parent 4b1f73f commit e3b796a

File tree

22 files changed

+522
-136
lines changed

22 files changed

+522
-136
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ Date: YYYY-MM-DD
203203
**Full Changelog**: [`v6.X.Y...v6.X.Y`](https://github.com/remix-run/react-router/compare/[email protected]@6.X.Y)
204204
-->
205205

206+
## v6.26.1
207+
208+
Date: 2024-08-15
209+
210+
### Patch Changes
211+
212+
- Rename `unstable_patchRoutesOnMiss` to `unstable_patchRoutesOnNavigation` to match new behavior ([#11888](https://github.com/remix-run/react-router/pull/11888))
213+
- Update `unstable_patchRoutesOnNavigation` logic so that we call the method when we match routes with dynamic param or splat segments in case there exists a higher-scoring static route that we've not yet discovered ([#11883](https://github.com/remix-run/react-router/pull/11883))
214+
- We also now leverage an internal FIFO queue of previous paths we've already called `unstable_patchRoutesOnNavigation` against so that we don't re-call on subsequent navigations to the same path
215+
216+
**Full Changelog**: [`v6.26.0...v6.26.1`](https://github.com/remix-run/react-router/compare/[email protected]@6.26.1)
217+
206218
## v6.26.0
207219

208220
Date: 2024-08-01

docs/routers/create-browser-router.md

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

387-
## `opts.unstable_patchRoutesOnMiss`
387+
## `opts.unstable_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_patchRoutesOnMiss` 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 `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.
398398

399399
### Type Declaration
400400

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

414414
### Overview
415415

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

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

@@ -427,7 +427,10 @@ const router = createBrowserRouter(
427427
},
428428
],
429429
{
430-
async unstable_patchRoutesOnMiss({ path, patch }) {
430+
async unstable_patchRoutesOnNavigation({
431+
path,
432+
patch,
433+
}) {
431434
if (path === "/a") {
432435
// Load/patch the `a` route as a child of the route with id `root`
433436
let route = await getARoute();
@@ -439,7 +442,7 @@ const router = createBrowserRouter(
439442
);
440443
```
441444

442-
In the above example, if the user clicks a link to `/a`, React Router won't be able to match it initially and will call `patchRoutesOnMiss` with `/a` and a `matches` array containing the root route match. By calling `patch`, the `a` route will be added to the route tree and React Router will perform matching again. This time it will successfully match the `/a` path and the navigation will complete successfully.
445+
In the above example, if the user clicks a link to `/a`, React Router won't be able to match it initially and will call `patchRoutesOnNavigation` with `/a` and a `matches` array containing the root route match. By calling `patch`, the `a` route will be added to the route tree and React Router will perform matching again. This time it will successfully match the `/a` path and the navigation will complete successfully.
443446

444447
**Patching new root-level routes**
445448

@@ -455,7 +458,10 @@ const router = createBrowserRouter(
455458
},
456459
],
457460
{
458-
async unstable_patchRoutesOnMiss({ path, patch }) {
461+
async unstable_patchRoutesOnNavigation({
462+
path,
463+
patch,
464+
}) {
459465
if (path === "/root-sibling") {
460466
// Load/patch the `/root-sibling` route as a sibling of the root route
461467
let route = await getRootSiblingRoute();
@@ -480,7 +486,10 @@ let router = createBrowserRouter(
480486
},
481487
],
482488
{
483-
async unstable_patchRoutesOnMiss({ path, patch }) {
489+
async unstable_patchRoutesOnNavigation({
490+
path,
491+
patch,
492+
}) {
484493
if (path.startsWith("/dashboard")) {
485494
let children = await import("./dashboard");
486495
patch(null, children);
@@ -510,7 +519,7 @@ let router = createBrowserRouter(
510519
children: [
511520
{
512521
// If we want to include /dashboard in the critical routes, we need to
513-
// also include it's index route since patchRoutesOnMiss will not be
522+
// also include it's index route since patchRoutesOnNavigation will not be
514523
// called on a navigation to `/dashboard` because it will have successfully
515524
// matched the `/dashboard` parent route
516525
index: true,
@@ -535,7 +544,10 @@ let router = createBrowserRouter(
535544
},
536545
],
537546
{
538-
async unstable_patchRoutesOnMiss({ matches, patch }) {
547+
async unstable_patchRoutesOnNavigation({
548+
matches,
549+
patch,
550+
}) {
539551
let leafRoute = matches[matches.length - 1]?.route;
540552
if (leafRoute?.handle?.lazyChildren) {
541553
let children =

docs/start/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ If we review the search form, it looks like this:
13641364
</form>
13651365
```
13661366
1367-
As we've seen before, browsers can serialize forms by the `name` attribute of its input elements. The name of this input is `q`, that's why the URL has `?q=`. If we named it `search` the URL would be `?search=`.
1367+
As we've seen before, browsers can serialize forms by the `name` attribute of it's input elements. The name of this input is `q`, that's why the URL has `?q=`. If we named it `search` the URL would be `?search=`.
13681368
13691369
Note that this form is different from the others we've used, it does not have `<form method="post">`. The default `method` is `"get"`. That means when the browser creates the request for the next document, it doesn't put the form data into the request POST body, but into the [`URLSearchParams`][urlsearchparams] of a GET request.
13701370

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"none": "17.3 kB"
118118
},
119119
"packages/react-router-dom/dist/umd/react-router-dom.production.min.js": {
120-
"none": "23.7 kB"
120+
"none": "23.8 kB"
121121
}
122122
},
123123
"pnpm": {

packages/react-router-dom-v5-compat/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# `react-router-dom-v5-compat`
22

3+
## 6.26.1
4+
5+
### Patch Changes
6+
7+
- Updated dependencies:
8+
- `@remix-run/[email protected]`
9+
10+
11+
312
## 6.26.0
413

514
### Patch Changes

packages/react-router-dom-v5-compat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-dom-v5-compat",
3-
"version": "6.26.0",
3+
"version": "6.26.1",
44
"description": "Migration path to React Router v6 from v4/5",
55
"keywords": [
66
"react",

packages/react-router-dom/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# `react-router-dom`
22

3+
## 6.26.1
4+
5+
### Patch Changes
6+
7+
- Rename `unstable_patchRoutesOnMiss` to `unstable_patchRoutesOnNavigation` to match new behavior ([#11888](https://github.com/remix-run/react-router/pull/11888))
8+
- Updated dependencies:
9+
- `@remix-run/[email protected]`
10+
11+
312
## 6.26.0
413

514
### Minor Changes

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("v7_partialHydration", () => {
3131
testPartialHydration(createMemoryRouter, ReactRouter_RouterProvider);
3232

3333
// these tests only run for memory since we just need to set initialEntries
34-
it("supports partial hydration w/patchRoutesOnMiss (leaf fallback)", async () => {
34+
it("supports partial hydration w/patchRoutesOnNavigation (leaf fallback)", async () => {
3535
let parentDfd = createDeferred();
3636
let childDfd = createDeferred();
3737
let router = createMemoryRouter(
@@ -69,7 +69,7 @@ describe("v7_partialHydration", () => {
6969
future: {
7070
v7_partialHydration: true,
7171
},
72-
unstable_patchRoutesOnMiss({ path, patch }) {
72+
unstable_patchRoutesOnNavigation({ path, patch }) {
7373
if (path === "/parent/child") {
7474
patch("parent", [
7575
{
@@ -119,7 +119,7 @@ describe("v7_partialHydration", () => {
119119
`);
120120
});
121121

122-
it("supports partial hydration w/patchRoutesOnMiss (root fallback)", async () => {
122+
it("supports partial hydration w/patchRoutesOnNavigation (root fallback)", async () => {
123123
let parentDfd = createDeferred();
124124
let childDfd = createDeferred();
125125
let router = createMemoryRouter(
@@ -157,7 +157,7 @@ describe("v7_partialHydration", () => {
157157
future: {
158158
v7_partialHydration: true,
159159
},
160-
unstable_patchRoutesOnMiss({ path, patch }) {
160+
unstable_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_PatchRoutesOnMissFunction,
19+
unstable_PatchRoutesOnNavigationFunction,
2020
} from "react-router";
2121
import {
2222
Router,
@@ -153,7 +153,7 @@ export type {
153153
To,
154154
UIMatch,
155155
unstable_HandlerResult,
156-
unstable_PatchRoutesOnMissFunction,
156+
unstable_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
unstable_dataStrategy?: unstable_DataStrategyFunction;
264-
unstable_patchRoutesOnMiss?: unstable_PatchRoutesOnMissFunction;
264+
unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction;
265265
window?: Window;
266266
}
267267

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

packages/react-router-dom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-dom",
3-
"version": "6.26.0",
3+
"version": "6.26.1",
44
"description": "Declarative routing for React web applications",
55
"keywords": [
66
"react",

0 commit comments

Comments
 (0)