From f18627f8fff91a18272166b783a97a2d3fbd59c1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 21 Jun 2023 15:48:25 +0000 Subject: [PATCH 1/2] chore: Update version for release (pre) --- .changeset/pre.json | 14 +++- .../react-router-dom-v5-compat/CHANGELOG.md | 9 +++ .../react-router-dom-v5-compat/package.json | 4 +- packages/react-router-dom/CHANGELOG.md | 66 +++++++++++++++++++ packages/react-router-dom/package.json | 6 +- packages/react-router-native/CHANGELOG.md | 8 +++ packages/react-router-native/package.json | 4 +- packages/react-router/CHANGELOG.md | 12 ++++ packages/react-router/package.json | 4 +- packages/router/CHANGELOG.md | 53 +++++++++++++++ packages/router/package.json | 2 +- 11 files changed, 171 insertions(+), 11 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 6af84fec5e..4dcae38cc3 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -8,5 +8,17 @@ "react-router-native": "6.13.0", "@remix-run/router": "1.6.3" }, - "changesets": [] + "changesets": [ + "blocker-key-strict-mode", + "formdata-submitter", + "purple-islands-cough", + "raw-payload-submission-router", + "raw-payload-submission", + "skip-fetcher-revalidate", + "smart-pots-repair", + "strip-basename-getkey", + "strip-blocker-basename", + "sync-window-location", + "tsc-skiplibcheck-react17" + ] } diff --git a/packages/react-router-dom-v5-compat/CHANGELOG.md b/packages/react-router-dom-v5-compat/CHANGELOG.md index 8f556e7ac7..ea6781c6d0 100644 --- a/packages/react-router-dom-v5-compat/CHANGELOG.md +++ b/packages/react-router-dom-v5-compat/CHANGELOG.md @@ -1,5 +1,14 @@ # `react-router-dom-v5-compat` +## 6.14.0-pre.0 + +### Patch Changes + +- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) +- Updated dependencies: + - `react-router@6.14.0-pre.0` + - `react-router-dom@6.14.0-pre.0` + ## 6.13.0 ### Patch Changes diff --git a/packages/react-router-dom-v5-compat/package.json b/packages/react-router-dom-v5-compat/package.json index bc520b9a99..a7579f3a97 100644 --- a/packages/react-router-dom-v5-compat/package.json +++ b/packages/react-router-dom-v5-compat/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom-v5-compat", - "version": "6.13.0", + "version": "6.14.0-pre.0", "description": "Migration path to React Router v6 from v4/5", "keywords": [ "react", @@ -24,7 +24,7 @@ "types": "./dist/index.d.ts", "dependencies": { "history": "^5.3.0", - "react-router": "6.13.0" + "react-router": "6.14.0-pre.0" }, "peerDependencies": { "react": ">=16.8", diff --git a/packages/react-router-dom/CHANGELOG.md b/packages/react-router-dom/CHANGELOG.md index 10c395031a..f60de391b1 100644 --- a/packages/react-router-dom/CHANGELOG.md +++ b/packages/react-router-dom/CHANGELOG.md @@ -1,5 +1,71 @@ # `react-router-dom` +## 6.14.0-pre.0 + +### Minor Changes + +- Add support for `application/json` and `text/plain` encodings for `useSubmit`/`fetcher.submit`. To reflect these additional types, `useNavigation`/`useFetcher` now also contain `navigation.json`/`navigation.text` and `fetcher.json`/`fetcher.text` which are getter functions mimicking `request.json` and `request.text`. Just as a `Request` does, if you access one of these methods for the incorrect encoding type, it will throw an Error (i.e. accessing `navigation.formData` when `navigation.formEncType` is `application/json`). ([#10413](https://github.com/remix-run/react-router/pull/10413)) + + ```jsx + // The default behavior will still serialize as FormData + function Component() { + let navigation = useNavigation(); + let submit = useSubmit(); + submit({ key: "value" }); + // navigation.formEncType => "application/x-www-form-urlencoded" + // navigation.formData => FormData instance + // navigation.text => "key=value" + } + + function action({ request }) { + // request.headers.get("Content-Type") => "application/x-www-form-urlencoded" + // request.formData => FormData instance + // request.text => "key=value" + } + ``` + + ```js + // Opt-into JSON encoding with `encType: "application/json"` + function Component() { + let submit = useSubmit(); + submit({ key: "value" }, { encType: "application/json" }); + // navigation.formEncType => "application/json" + // navigation.json => { key: "value" } + // navigation.text => '{"key":"value"}' + } + + function action({ request }) { + // request.headers.get("Content-Type") => "application/json" + // request.json => { key: "value" } + // request.text => '{"key":"value"}' + } + ``` + + ```js + // Opt-into JSON encoding with `encType: "application/json"` + function Component() { + let submit = useSubmit(); + submit("Text submission", { encType: "text/plain" }); + // navigation.formEncType => "text/plain" + // navigation.text => "Text submission" + } + + function action({ request }) { + // request.headers.get("Content-Type") => "text/plain" + // request.text => "Text submission" + } + ``` + +### Patch Changes + +- When submitting a form from a `submitter` element, prefer the built-in `new FormData(form, submitter)` instead of the previous manual approach in modern browsers (those that support the new `submitter` parameter). For browsers that don't support it, we continue to just append the submit button's entry to the end, and we also add rudimentary support for `type="image"` buttons. If developers want full spec-compliant support for legacy browsers, they can use the `formdata-submitter-polyfill`. ([#9865](https://github.com/remix-run/react-router/pull/9865)) +- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) +- Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering. However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.) ([#10211](https://github.com/remix-run/react-router/pull/10211)) +- Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622)) +- Updated dependencies: + - `react-router@6.14.0-pre.0` + - `@remix-run/router@1.7.0-pre.0` + ## 6.13.0 ### Minor Changes diff --git a/packages/react-router-dom/package.json b/packages/react-router-dom/package.json index 0363c2ed91..bc6fcb5eba 100644 --- a/packages/react-router-dom/package.json +++ b/packages/react-router-dom/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom", - "version": "6.13.0", + "version": "6.14.0-pre.0", "description": "Declarative routing for React web applications", "keywords": [ "react", @@ -23,8 +23,8 @@ "module": "./dist/index.js", "types": "./dist/index.d.ts", "dependencies": { - "@remix-run/router": "1.6.3", - "react-router": "6.13.0" + "@remix-run/router": "1.7.0-pre.0", + "react-router": "6.14.0-pre.0" }, "devDependencies": { "react": "^18.2.0", diff --git a/packages/react-router-native/CHANGELOG.md b/packages/react-router-native/CHANGELOG.md index 6bba29b74b..0968e93d7c 100644 --- a/packages/react-router-native/CHANGELOG.md +++ b/packages/react-router-native/CHANGELOG.md @@ -1,5 +1,13 @@ # `react-router-native` +## 6.14.0-pre.0 + +### Patch Changes + +- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) +- Updated dependencies: + - `react-router@6.14.0-pre.0` + ## 6.13.0 ### Patch Changes diff --git a/packages/react-router-native/package.json b/packages/react-router-native/package.json index 4c8f909def..603958f316 100644 --- a/packages/react-router-native/package.json +++ b/packages/react-router-native/package.json @@ -1,6 +1,6 @@ { "name": "react-router-native", - "version": "6.13.0", + "version": "6.14.0-pre.0", "description": "Declarative routing for React Native applications", "keywords": [ "react", @@ -22,7 +22,7 @@ "types": "./dist/index.d.ts", "dependencies": { "@ungap/url-search-params": "^0.1.4", - "react-router": "6.13.0" + "react-router": "6.14.0-pre.0" }, "devDependencies": { "react": "^18.2.0", diff --git a/packages/react-router/CHANGELOG.md b/packages/react-router/CHANGELOG.md index 0caac4d8b0..1dfe16a486 100644 --- a/packages/react-router/CHANGELOG.md +++ b/packages/react-router/CHANGELOG.md @@ -1,5 +1,17 @@ # `react-router` +## 6.14.0-pre.0 + +### Patch Changes + +- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573)) +- Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612)) +- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) +- Strip `basename` from locations provided to `unstable_useBlocker` functions to match `useLocation` ([#10573](https://github.com/remix-run/react-router/pull/10573)) +- Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622)) +- Updated dependencies: + - `@remix-run/router@1.7.0-pre.0` + ## 6.13.0 ### Minor Changes diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 820a336697..31910b6987 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -1,6 +1,6 @@ { "name": "react-router", - "version": "6.13.0", + "version": "6.14.0-pre.0", "description": "Declarative routing for React", "keywords": [ "react", @@ -23,7 +23,7 @@ "module": "./dist/index.js", "types": "./dist/index.d.ts", "dependencies": { - "@remix-run/router": "1.6.3" + "@remix-run/router": "1.7.0-pre.0" }, "devDependencies": { "react": "^18.2.0" diff --git a/packages/router/CHANGELOG.md b/packages/router/CHANGELOG.md index c970a1c7c5..a74d3566ae 100644 --- a/packages/router/CHANGELOG.md +++ b/packages/router/CHANGELOG.md @@ -1,5 +1,58 @@ # `@remix-run/router` +## 1.7.0-pre.0 + +### Minor Changes + +- Add support for `application/json` and `text/plain` encodings for `router.navigate`/`router.fetch` submissions. To leverage these encodings, pass your data in a `body` parameter and specify the desired `formEncType`: ([#10413](https://github.com/remix-run/react-router/pull/10413)) + + ```js + // By default, the encoding is "application/x-www-form-urlencoded" + router.navigate("/", { + formMethod: "post", + body: { key: "value" }, + }); + + function action({ request }) { + // request.formData => FormData instance with entry [key=value] + // request.text => "key=value" + } + ``` + + ```js + // Pass `formEncType` to opt-into a different encoding + router.navigate("/", { + formMethod: "post", + formEncType: "application/json", + body: { key: "value" }, + }); + + function action({ request }) { + // request.json => { key: "value" } + // request.text => '{ "key":"value" }' + } + ``` + + ```js + router.navigate("/", { + formMethod: "post", + formEncType: "text/plain", + body: "Text submission", + }); + + function action({ request }) { + // request.text => "Text submission" + } + ``` + +### Patch Changes + +- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573)) +- Avoid calling `shouldRevalidate` for fetchers that have not yet completed a data load ([#10623](https://github.com/remix-run/react-router/pull/10623)) +- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) +- Strip `basename` from the `location` provided to `` to match the `useLocation` behavior ([#10550](https://github.com/remix-run/react-router/pull/10550)) +- Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering. However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.) ([#10211](https://github.com/remix-run/react-router/pull/10211)) + ## 1.6.3 ### Patch Changes diff --git a/packages/router/package.json b/packages/router/package.json index fc562c2f9c..e1166feea3 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@remix-run/router", - "version": "1.6.3", + "version": "1.7.0-pre.0", "description": "Nested/Data-driven/Framework-agnostic Routing", "keywords": [ "remix", From 163ec61a372daf2e7bb46cc8183e71abae95b35e Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 21 Jun 2023 12:03:58 -0400 Subject: [PATCH 2/2] Update changelogs --- .changeset/raw-payload-submission-router.md | 14 ++++++------- .changeset/raw-payload-submission.md | 18 +++++++--------- .changeset/smart-pots-repair.md | 2 +- packages/react-router-dom/CHANGELOG.md | 20 +++++++----------- packages/react-router/CHANGELOG.md | 6 +++--- packages/router/CHANGELOG.md | 23 +++++++++++---------- 6 files changed, 37 insertions(+), 46 deletions(-) diff --git a/.changeset/raw-payload-submission-router.md b/.changeset/raw-payload-submission-router.md index 06634bcd9b..bcd11df0df 100644 --- a/.changeset/raw-payload-submission-router.md +++ b/.changeset/raw-payload-submission-router.md @@ -11,9 +11,8 @@ router.navigate("/", { body: { key: "value" }, }); -function action({ request }) { - // request.formData => FormData instance with entry [key=value] - // request.text => "key=value" +async function action({ request }) { + // await request.formData() => FormData instance with entry [key=value] } ``` @@ -25,9 +24,8 @@ router.navigate("/", { body: { key: "value" }, }); -function action({ request }) { - // request.json => { key: "value" } - // request.text => '{ "key":"value" }' +async function action({ request }) { + // await request.json() => { key: "value" } } ``` @@ -38,7 +36,7 @@ router.navigate("/", { body: "Text submission", }); -function action({ request }) { - // request.text => "Text submission" +async function action({ request }) { + // await request.text() => "Text submission" } ``` diff --git a/.changeset/raw-payload-submission.md b/.changeset/raw-payload-submission.md index ab804c3f02..2981b6f5d0 100644 --- a/.changeset/raw-payload-submission.md +++ b/.changeset/raw-payload-submission.md @@ -2,7 +2,7 @@ "react-router-dom": minor --- -Add support for `application/json` and `text/plain` encodings for `useSubmit`/`fetcher.submit`. To reflect these additional types, `useNavigation`/`useFetcher` now also contain `navigation.json`/`navigation.text` and `fetcher.json`/`fetcher.text` which are getter functions mimicking `request.json` and `request.text`. Just as a `Request` does, if you access one of these methods for the incorrect encoding type, it will throw an Error (i.e. accessing `navigation.formData` when `navigation.formEncType` is `application/json`). +Add support for `application/json` and `text/plain` encodings for `useSubmit`/`fetcher.submit`. To reflect these additional types, `useNavigation`/`useFetcher` now also contain `navigation.json`/`navigation.text` and `fetcher.json`/`fetcher.text` which include the json/text submission if applicable. ```jsx // The default behavior will still serialize as FormData @@ -12,13 +12,11 @@ function Component() { submit({ key: "value" }); // navigation.formEncType => "application/x-www-form-urlencoded" // navigation.formData => FormData instance - // navigation.text => "key=value" } -function action({ request }) { +async function action({ request }) { // request.headers.get("Content-Type") => "application/x-www-form-urlencoded" - // request.formData => FormData instance - // request.text => "key=value" + // await request.formData() => FormData instance } ``` @@ -29,13 +27,11 @@ function Component() { submit({ key: "value" }, { encType: "application/json" }); // navigation.formEncType => "application/json" // navigation.json => { key: "value" } - // navigation.text => '{"key":"value"}' } -function action({ request }) { +async function action({ request }) { // request.headers.get("Content-Type") => "application/json" - // request.json => { key: "value" } - // request.text => '{"key":"value"}' + // await request.json => { key: "value" } } ``` @@ -48,8 +44,8 @@ function Component() { // navigation.text => "Text submission" } -function action({ request }) { +async function action({ request }) { // request.headers.get("Content-Type") => "text/plain" - // request.text => "Text submission" + // await request.text() => "Text submission" } ``` diff --git a/.changeset/smart-pots-repair.md b/.changeset/smart-pots-repair.md index 75220242f8..4c292766a1 100644 --- a/.changeset/smart-pots-repair.md +++ b/.changeset/smart-pots-repair.md @@ -6,4 +6,4 @@ "@remix-run/router": patch --- -upgrade typescript to 5.1 +Upgrade `typescript` to 5.1 diff --git a/packages/react-router-dom/CHANGELOG.md b/packages/react-router-dom/CHANGELOG.md index f60de391b1..ac261e2d1a 100644 --- a/packages/react-router-dom/CHANGELOG.md +++ b/packages/react-router-dom/CHANGELOG.md @@ -4,7 +4,7 @@ ### Minor Changes -- Add support for `application/json` and `text/plain` encodings for `useSubmit`/`fetcher.submit`. To reflect these additional types, `useNavigation`/`useFetcher` now also contain `navigation.json`/`navigation.text` and `fetcher.json`/`fetcher.text` which are getter functions mimicking `request.json` and `request.text`. Just as a `Request` does, if you access one of these methods for the incorrect encoding type, it will throw an Error (i.e. accessing `navigation.formData` when `navigation.formEncType` is `application/json`). ([#10413](https://github.com/remix-run/react-router/pull/10413)) +- Add support for `application/json` and `text/plain` encodings for `useSubmit`/`fetcher.submit`. To reflect these additional types, `useNavigation`/`useFetcher` now also contain `navigation.json`/`navigation.text` and `fetcher.json`/`fetcher.text` which include the json/text submission if applicable. ([#10413](https://github.com/remix-run/react-router/pull/10413)) ```jsx // The default behavior will still serialize as FormData @@ -14,13 +14,11 @@ submit({ key: "value" }); // navigation.formEncType => "application/x-www-form-urlencoded" // navigation.formData => FormData instance - // navigation.text => "key=value" } - function action({ request }) { + async function action({ request }) { // request.headers.get("Content-Type") => "application/x-www-form-urlencoded" - // request.formData => FormData instance - // request.text => "key=value" + // await request.formData() => FormData instance } ``` @@ -31,13 +29,11 @@ submit({ key: "value" }, { encType: "application/json" }); // navigation.formEncType => "application/json" // navigation.json => { key: "value" } - // navigation.text => '{"key":"value"}' } - function action({ request }) { + async function action({ request }) { // request.headers.get("Content-Type") => "application/json" - // request.json => { key: "value" } - // request.text => '{"key":"value"}' + // await request.json => { key: "value" } } ``` @@ -50,16 +46,16 @@ // navigation.text => "Text submission" } - function action({ request }) { + async function action({ request }) { // request.headers.get("Content-Type") => "text/plain" - // request.text => "Text submission" + // await request.text() => "Text submission" } ``` ### Patch Changes - When submitting a form from a `submitter` element, prefer the built-in `new FormData(form, submitter)` instead of the previous manual approach in modern browsers (those that support the new `submitter` parameter). For browsers that don't support it, we continue to just append the submit button's entry to the end, and we also add rudimentary support for `type="image"` buttons. If developers want full spec-compliant support for legacy browsers, they can use the `formdata-submitter-polyfill`. ([#9865](https://github.com/remix-run/react-router/pull/9865)) -- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) +- upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) - Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering. However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.) ([#10211](https://github.com/remix-run/react-router/pull/10211)) - Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622)) - Updated dependencies: diff --git a/packages/react-router/CHANGELOG.md b/packages/react-router/CHANGELOG.md index 1dfe16a486..c8e8465e36 100644 --- a/packages/react-router/CHANGELOG.md +++ b/packages/react-router/CHANGELOG.md @@ -4,11 +4,11 @@ ### Patch Changes -- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573)) -- Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612)) -- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) - Strip `basename` from locations provided to `unstable_useBlocker` functions to match `useLocation` ([#10573](https://github.com/remix-run/react-router/pull/10573)) +- Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612)) +- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573)) - Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622)) +- upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) - Updated dependencies: - `@remix-run/router@1.7.0-pre.0` diff --git a/packages/router/CHANGELOG.md b/packages/router/CHANGELOG.md index a74d3566ae..a714651d8f 100644 --- a/packages/router/CHANGELOG.md +++ b/packages/router/CHANGELOG.md @@ -13,9 +13,9 @@ body: { key: "value" }, }); - function action({ request }) { - // request.formData => FormData instance with entry [key=value] - // request.text => "key=value" + async function action({ request }) { + let formData = await request.formData(); + // formData => FormData instance with entry [key=value] } ``` @@ -27,9 +27,9 @@ body: { key: "value" }, }); - function action({ request }) { - // request.json => { key: "value" } - // request.text => '{ "key":"value" }' + async function action({ request }) { + let json = await request.json(); + // json => { key: "value" } } ``` @@ -40,18 +40,19 @@ body: "Text submission", }); - function action({ request }) { - // request.text => "Text submission" + async function action({ request }) { + let text = await request.text(); + // text => "Text submission" } ``` ### Patch Changes -- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573)) +- Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering. However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.) ([#10211](https://github.com/remix-run/react-router/pull/10211)) - Avoid calling `shouldRevalidate` for fetchers that have not yet completed a data load ([#10623](https://github.com/remix-run/react-router/pull/10623)) -- upgrade typescript to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) - Strip `basename` from the `location` provided to `` to match the `useLocation` behavior ([#10550](https://github.com/remix-run/react-router/pull/10550)) -- Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering. However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.) ([#10211](https://github.com/remix-run/react-router/pull/10211)) +- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573)) +- Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) ## 1.6.3