|
1 | 1 | # `react-router-dom` |
2 | 2 |
|
| 3 | +## 6.14.0-pre.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- 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)) |
| 8 | + |
| 9 | + ```jsx |
| 10 | + // The default behavior will still serialize as FormData |
| 11 | + function Component() { |
| 12 | + let navigation = useNavigation(); |
| 13 | + let submit = useSubmit(); |
| 14 | + submit({ key: "value" }); |
| 15 | + // navigation.formEncType => "application/x-www-form-urlencoded" |
| 16 | + // navigation.formData => FormData instance |
| 17 | + } |
| 18 | + |
| 19 | + async function action({ request }) { |
| 20 | + // request.headers.get("Content-Type") => "application/x-www-form-urlencoded" |
| 21 | + // await request.formData() => FormData instance |
| 22 | + } |
| 23 | + ``` |
| 24 | + |
| 25 | + ```js |
| 26 | + // Opt-into JSON encoding with `encType: "application/json"` |
| 27 | + function Component() { |
| 28 | + let submit = useSubmit(); |
| 29 | + submit({ key: "value" }, { encType: "application/json" }); |
| 30 | + // navigation.formEncType => "application/json" |
| 31 | + // navigation.json => { key: "value" } |
| 32 | + } |
| 33 | + |
| 34 | + async function action({ request }) { |
| 35 | + // request.headers.get("Content-Type") => "application/json" |
| 36 | + // await request.json => { key: "value" } |
| 37 | + } |
| 38 | + ``` |
| 39 | + |
| 40 | + ```js |
| 41 | + // Opt-into JSON encoding with `encType: "application/json"` |
| 42 | + function Component() { |
| 43 | + let submit = useSubmit(); |
| 44 | + submit("Text submission", { encType: "text/plain" }); |
| 45 | + // navigation.formEncType => "text/plain" |
| 46 | + // navigation.text => "Text submission" |
| 47 | + } |
| 48 | + |
| 49 | + async function action({ request }) { |
| 50 | + // request.headers.get("Content-Type") => "text/plain" |
| 51 | + // await request.text() => "Text submission" |
| 52 | + } |
| 53 | + ``` |
| 54 | + |
| 55 | +### Patch Changes |
| 56 | + |
| 57 | +- 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)) |
| 58 | +- upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581)) |
| 59 | +- 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)) |
| 60 | +- Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622)) |
| 61 | +- Updated dependencies: |
| 62 | + |
| 63 | + |
| 64 | + |
3 | 65 | ## 6.13.0 |
4 | 66 |
|
5 | 67 | ### Minor Changes |
|
0 commit comments