Skip to content

Commit 618a5be

Browse files
authored
Remove future.v7_normalizeFormMethod (#11697)
* Remove future.v7_normalizeFormMethod * fix build * Fix tests
1 parent 714a2c5 commit 618a5be

16 files changed

+56
-74
lines changed

.changeset/fair-cheetahs-hope.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"react-router-dom": major
3+
"react-router": major
4+
---
5+
6+
Remove `future.v7_normalizeFormMethod` future flag

packages/react-router-dom/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export type {
7777
FormMethod,
7878
GetScrollRestorationKeyFunction,
7979
StaticHandlerContext,
80-
V7_FormMethod,
8180
BrowserRouterProps,
8281
HashRouterProps,
8382
HistoryRouterProps,

packages/react-router/__tests__/router/fetchers-test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe("fetchers", () => {
169169
formData: createFormData({ key: "value" }),
170170
});
171171
expect(A.fetcher.state).toBe("loading");
172-
expect(A.fetcher.formMethod).toBe("get");
172+
expect(A.fetcher.formMethod).toBe("GET");
173173
expect(A.fetcher.formAction).toBe("/foo");
174174
expect(A.fetcher.formData).toEqual(createFormData({ key: "value" }));
175175
expect(A.fetcher.formEncType).toBe("application/x-www-form-urlencoded");
@@ -2111,7 +2111,7 @@ describe("fetchers", () => {
21112111
"formAction": "/two/three",
21122112
"formData": FormData {},
21132113
"formEncType": "application/x-www-form-urlencoded",
2114-
"formMethod": "post",
2114+
"formMethod": "POST",
21152115
"json": undefined,
21162116
"nextParams": {
21172117
"a": "two",

packages/react-router/__tests__/router/navigation-test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ describe("navigations", () => {
11541154
// @ts-expect-error
11551155
new URLSearchParams(navigation.formData).toString()
11561156
).toBe("gosh=dang");
1157-
expect(navigation.formMethod).toBe("post");
1157+
expect(navigation.formMethod).toBe("POST");
11581158
expect(navigation.formEncType).toBe("application/x-www-form-urlencoded");
11591159
expect(navigation.location).toMatchObject({
11601160
pathname: "/foo",
@@ -1169,7 +1169,7 @@ describe("navigations", () => {
11691169
// @ts-expect-error
11701170
new URLSearchParams(navigation.formData).toString()
11711171
).toBe("gosh=dang");
1172-
expect(navigation.formMethod).toBe("post");
1172+
expect(navigation.formMethod).toBe("POST");
11731173
expect(navigation.formEncType).toBe("application/x-www-form-urlencoded");
11741174
expect(navigation.location).toMatchObject({
11751175
pathname: "/foo",
@@ -1203,7 +1203,7 @@ describe("navigations", () => {
12031203
// @ts-expect-error
12041204
new URLSearchParams(navigation.formData).toString()
12051205
).toBe("gosh=dang");
1206-
expect(navigation.formMethod).toBe("post");
1206+
expect(navigation.formMethod).toBe("POST");
12071207
expect(navigation.location).toMatchObject({
12081208
pathname: "/bar",
12091209
search: "",
@@ -1229,7 +1229,7 @@ describe("navigations", () => {
12291229
let navigation = t.router.state.navigation;
12301230
expect(navigation.state).toBe("loading");
12311231
expect(navigation.formData).toEqual(createFormData({ gosh: "dang" }));
1232-
expect(navigation.formMethod).toBe("get");
1232+
expect(navigation.formMethod).toBe("GET");
12331233
expect(navigation.formEncType).toBe("application/x-www-form-urlencoded");
12341234
expect(navigation.location).toMatchObject({
12351235
pathname: "/foo",
@@ -1257,7 +1257,7 @@ describe("navigations", () => {
12571257
let navigation = t.router.state.navigation;
12581258
expect(navigation.state).toBe("loading");
12591259
expect(navigation.formData).toEqual(createFormData({ gosh: "dang" }));
1260-
expect(navigation.formMethod).toBe("get");
1260+
expect(navigation.formMethod).toBe("GET");
12611261
expect(navigation.formEncType).toBe("application/x-www-form-urlencoded");
12621262
expect(navigation.location?.pathname).toBe("/bar");
12631263

packages/react-router/__tests__/router/revalidate-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ describe("router.revalidate", () => {
271271
pathname: "/tasks",
272272
search: "?key=value",
273273
},
274-
formMethod: "get",
274+
formMethod: "GET",
275275
formData: createFormData({ key: "value" }),
276276
},
277277
revalidation: "loading",

packages/react-router/__tests__/router/router-test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ describe("a router", () => {
690690
pathname: "/tasks",
691691
search: "?key=value",
692692
});
693-
expect(t.router.state.navigation.formMethod).toBe("get");
693+
expect(t.router.state.navigation.formMethod).toBe("GET");
694694
expect(t.router.state.navigation.formData).toEqual(
695695
createFormData({ key: "value" })
696696
);
@@ -710,7 +710,7 @@ describe("a router", () => {
710710
pathname: "/tasks",
711711
search: "?key=value",
712712
});
713-
expect(t.router.state.navigation.formMethod).toBe("get");
713+
expect(t.router.state.navigation.formMethod).toBe("GET");
714714
expect(t.router.state.navigation.formData).toEqual(
715715
createFormData({ key: "value" })
716716
);
@@ -730,7 +730,7 @@ describe("a router", () => {
730730
pathname: "/tasks",
731731
search: "?key=2",
732732
});
733-
expect(t.router.state.navigation.formMethod).toBe("get");
733+
expect(t.router.state.navigation.formMethod).toBe("GET");
734734
expect(t.router.state.navigation.formData).toEqual(
735735
createFormData({ key: "2" })
736736
);
@@ -750,7 +750,7 @@ describe("a router", () => {
750750
pathname: "/tasks",
751751
search: "?key=1",
752752
});
753-
expect(t.router.state.navigation.formMethod).toBe("post");
753+
expect(t.router.state.navigation.formMethod).toBe("POST");
754754
expect(t.router.state.navigation.formData).toEqual(
755755
createFormData({ key: "2" })
756756
);

packages/react-router/__tests__/router/should-revalidate-test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ describe("shouldRevalidate", () => {
256256
nextParams: {},
257257
nextUrl: expect.urlMatch("http://localhost/child"),
258258
defaultShouldRevalidate: true,
259-
formMethod: "post",
259+
formMethod: "POST",
260260
formAction: "/child",
261261
formEncType: "application/x-www-form-urlencoded",
262262
actionResult: "ACTION",
@@ -310,7 +310,7 @@ describe("shouldRevalidate", () => {
310310
nextParams: {},
311311
nextUrl: expect.urlMatch("http://localhost/"),
312312
defaultShouldRevalidate: true,
313-
formMethod: "post",
313+
formMethod: "POST",
314314
formAction: "/child",
315315
formEncType: "application/x-www-form-urlencoded",
316316
actionResult: undefined,
@@ -364,7 +364,7 @@ describe("shouldRevalidate", () => {
364364
nextParams: {},
365365
nextUrl: expect.urlMatch("http://localhost/child"),
366366
defaultShouldRevalidate: true,
367-
formMethod: "post",
367+
formMethod: "POST",
368368
formAction: "/child",
369369
formEncType: "application/x-www-form-urlencoded",
370370
actionResult: "ACTION",
@@ -406,7 +406,7 @@ describe("shouldRevalidate", () => {
406406
// @ts-expect-error
407407
let arg = shouldRevalidate.mock.calls[0][0];
408408
let expectedArg: Partial<ShouldRevalidateFunctionArgs> = {
409-
formMethod: "post",
409+
formMethod: "POST",
410410
formAction: "/",
411411
formEncType: "application/json",
412412
text: undefined,
@@ -448,7 +448,7 @@ describe("shouldRevalidate", () => {
448448
// @ts-expect-error
449449
let arg = shouldRevalidate.mock.calls[0][0];
450450
let expectedArg: Partial<ShouldRevalidateFunctionArgs> = {
451-
formMethod: "post",
451+
formMethod: "POST",
452452
formAction: "/",
453453
formEncType: "text/plain",
454454
text: "hello world",
@@ -657,7 +657,7 @@ describe("shouldRevalidate", () => {
657657
formAction: "/child",
658658
formData: createFormData({}),
659659
formEncType: "application/x-www-form-urlencoded",
660-
formMethod: "post",
660+
formMethod: "POST",
661661
defaultShouldRevalidate: true,
662662
});
663663

@@ -715,7 +715,7 @@ describe("shouldRevalidate", () => {
715715
"formAction": "/fetch",
716716
"formData": FormData {},
717717
"formEncType": "application/x-www-form-urlencoded",
718-
"formMethod": "post",
718+
"formMethod": "POST",
719719
"json": undefined,
720720
"nextParams": {},
721721
"nextUrl": "http://localhost/",
@@ -779,7 +779,7 @@ describe("shouldRevalidate", () => {
779779
"formAction": "/fetch",
780780
"formData": FormData {},
781781
"formEncType": "application/x-www-form-urlencoded",
782-
"formMethod": "post",
782+
"formMethod": "POST",
783783
"json": undefined,
784784
"nextParams": {},
785785
"nextUrl": "http://localhost/",

packages/react-router/__tests__/router/submission-test.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -504,16 +504,16 @@ describe("submissions", () => {
504504
formMethod: "get",
505505
formData: createFormData({}),
506506
});
507-
expect(t.router.state.navigation.formMethod).toBe("get");
507+
expect(t.router.state.navigation.formMethod).toBe("GET");
508508
await A.loaders.child.resolve("LOADER");
509509
expect(t.router.state.navigation.formMethod).toBeUndefined();
510510
await t.router.navigate("/");
511511

512512
let B = await t.navigate("/child", {
513-
formMethod: "POST",
513+
formMethod: "post",
514514
formData: createFormData({}),
515515
});
516-
expect(t.router.state.navigation.formMethod).toBe("post");
516+
expect(t.router.state.navigation.formMethod).toBe("POST");
517517
await B.actions.child.resolve("ACTION");
518518
await B.loaders.child.resolve("LOADER");
519519
expect(t.router.state.navigation.formMethod).toBeUndefined();
@@ -523,20 +523,20 @@ describe("submissions", () => {
523523
formMethod: "GET",
524524
formData: createFormData({}),
525525
});
526-
expect(t.router.state.fetchers.get("key")?.formMethod).toBe("get");
526+
expect(t.router.state.fetchers.get("key")?.formMethod).toBe("GET");
527527
await C.loaders.child.resolve("LOADER FETCH");
528528
expect(t.router.state.fetchers.get("key")?.formMethod).toBeUndefined();
529529

530530
let D = await t.fetch("/child", "key", {
531-
formMethod: "post",
531+
formMethod: "POST",
532532
formData: createFormData({}),
533533
});
534-
expect(t.router.state.fetchers.get("key")?.formMethod).toBe("post");
534+
expect(t.router.state.fetchers.get("key")?.formMethod).toBe("POST");
535535
await D.actions.child.resolve("ACTION FETCH");
536536
expect(t.router.state.fetchers.get("key")?.formMethod).toBeUndefined();
537537
});
538538

539-
it("normalizes to uppercase in v7 via v7_normalizeFormMethod", async () => {
539+
it("normalizes to uppercase", async () => {
540540
let t = setup({
541541
routes: [
542542
{
@@ -553,7 +553,6 @@ describe("submissions", () => {
553553
},
554554
],
555555
future: {
556-
v7_normalizeFormMethod: true,
557556
v7_prependBasename: false,
558557
},
559558
});

packages/react-router/__tests__/router/utils/data-router-setup.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ export function setup({
507507
// Otherwise we should only need a loader for the leaf match
508508
let activeLoaderMatches = [match];
509509
// @ts-expect-error
510-
if (opts?.formMethod != null && opts.formMethod.toLowerCase() !== "get") {
510+
if (opts?.formMethod != null && opts.formMethod.toUpperCase() !== "GET") {
511511
if (currentRouter.state.navigation?.location) {
512512
let matches = matchRoutes(
513513
inFlightRoutes || currentRouter.routes,
@@ -572,7 +572,7 @@ export function setup({
572572
invariant(currentRouter, "No currentRouter available");
573573

574574
// @ts-expect-error
575-
if (opts?.formMethod != null && opts.formMethod.toLowerCase() !== "get") {
575+
if (opts?.formMethod != null && opts.formMethod.toUpperCase() !== "GET") {
576576
activeActionType = "navigation";
577577
activeActionNavigationId = navigationId;
578578
// Assume happy path and mark this navigations loaders as active. Even if
@@ -662,7 +662,7 @@ export function setup({
662662
invariant(currentRouter, "No currentRouter available");
663663

664664
// @ts-expect-error
665-
if (opts?.formMethod != null && opts.formMethod.toLowerCase() !== "get") {
665+
if (opts?.formMethod != null && opts.formMethod.toUpperCase() !== "GET") {
666666
activeActionType = "fetch";
667667
activeActionFetchId = navigationId;
668668
} else {

packages/react-router/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ export type {
258258
GetScrollRestorationKeyFunction,
259259
StaticHandlerContext,
260260
Submission,
261-
V7_FormMethod,
262261
} from "./lib/router";
263262

264263
export type {

packages/react-router/lib/dom/dom.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export type URLSearchParamsInit =
5959
supports arrays as values in the object form of the initializer
6060
instead of just strings. This is convenient when you need multiple
6161
values for a given key, but don't want to use an array initializer.
62-
62+
6363
For example, instead of:
64-
64+
6565
```tsx
6666
let searchParams = new URLSearchParams([
6767
['sort', 'name'],

packages/react-router/lib/dom/server.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ export function createStaticRouter(
304304
get future() {
305305
return {
306306
v7_fetcherPersist: false,
307-
v7_normalizeFormMethod: false,
308307
v7_partialHydration: opts.future?.v7_partialHydration === true,
309308
v7_prependBasename: false,
310309
unstable_skipActionErrorRevalidation: false,

packages/react-router/lib/dom/ssr/browser.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ function createHydratedRouter(): RemixRouter {
162162
history: createBrowserHistory(),
163163
basename: ssrInfo.context.basename,
164164
future: {
165-
v7_normalizeFormMethod: true,
166165
v7_fetcherPersist: ssrInfo.context.future.v3_fetcherPersist,
167166
v7_partialHydration: true,
168167
v7_prependBasename: true,

packages/react-router/lib/router/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export type {
3535
TrackedPromise,
3636
UIMatch,
3737
UpperCaseFormMethod,
38-
V7_FormMethod,
3938
} from "./utils";
4039

4140
export {

0 commit comments

Comments
 (0)