Skip to content

Commit 11156ac

Browse files
committed
Merge branch 'release-next'
2 parents 3204964 + c3c2f29 commit 11156ac

File tree

27 files changed

+1356
-193
lines changed

27 files changed

+1356
-193
lines changed

docs/components/form.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,15 @@ Instructs the form to replace the current entry in the history stack, instead of
179179
<Form replace />
180180
```
181181

182-
The default behavior is conditional on the form `method`:
183-
184-
- `get` defaults to `false`
185-
- every other method defaults to `true` if your `action` is successful
186-
- if your `action` redirects or throws, then it will still push by default
182+
The default behavior is conditional on the form behavior:
183+
184+
- `method=get` forms default to `false`
185+
- submission methods depend on the `formAction` and `action` behavior:
186+
- if your `action` throws, then it will default to `false`
187+
- if your `action` redirects to the current location, it defaults to `true`
188+
- if your `action` redirects elsewhere, it defaults to `false`
189+
- if your `formAction` is the current location, it defaults to `true`
190+
- otherwise it defaults to `false`
187191

188192
We've found with `get` you often want the user to be able to click "back" to see the previous search results/filters, etc. But with the other methods the default is `true` to avoid the "are you sure you want to resubmit the form?" prompt. Note that even if `replace={false}` React Router _will not_ resubmit the form when the back button is clicked and the method is post, put, patch, or delete.
189193

docs/hooks/use-before-unload.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: useBeforeUnload
3+
new: true
4+
---
5+
6+
# `useBeforeUnload`
7+
8+
This hook is just a helper around `window.onbeforeunload`. It can be useful to save important application state on the page (to something like the browser's local storage), before the user navigates away from your page. That way if they come back you can restore any stateful information (restore form input values, etc.)
9+
10+
```tsx lines=[1,7-11]
11+
import { useBeforeUnload } from "react-router-dom";
12+
13+
function SomeForm() {
14+
const [state, setState] = React.useState(null);
15+
16+
// save it off before users navigate away
17+
useBeforeUnload(
18+
React.useCallback(() => {
19+
localStorage.stuff = state;
20+
}, [state])
21+
);
22+
23+
// read it in when they return
24+
React.useEffect(() => {
25+
if (state === null && localStorage.stuff != null) {
26+
setState(localStorage.stuff);
27+
}
28+
}, [state]);
29+
30+
return <>{/*... */}</>;
31+
}
32+
```

examples/ssr-data-router/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This example contains a server (see [server.js](server.js)) that can run in both
1313

1414
In the browser entry point (see [src/entry.client.tsx](src/entry.client.tsx)), we use React Router like we would traditionally do in a purely client-side app and render a `<DataBrowserRouter>` to provide routing context to the rest of the app. The main difference is that instead of using `ReactDOM.createRoot(el).render()` to render the app, since the HTML was already sent by the server, all we need is `ReactDOM.hydrateRoot()`.
1515

16-
On the server (see [src/entry.server.tsx](src/entry.server.tsx)), we create a static request handler using `createStaticHandler` and query for the incoming `Request` we get from Express (note that we convert the Express request to a Web Fetch Request). Once the router is finished with data loading, we use React Router's `<unstable_DataStaticRouter>` to render the app in the correct state.
16+
On the server (see [src/entry.server.tsx](src/entry.server.tsx)), we create a static request handler using `createStaticHandler` and query for the incoming `Request` we get from Express (note that we convert the Express request to a Web Fetch Request). Once the router is finished with data loading, we use React Router's `<DataStaticRouter>` to render the app in the correct state.
1717

1818
## Preview
1919

examples/ssr-data-router/src/entry.server.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type * as express from "express";
2-
import { unstable_createStaticHandler as createStaticHandler } from "@remix-run/router";
2+
import { createStaticHandler } from "@remix-run/router";
33
import * as React from "react";
44
import ReactDOMServer from "react-dom/server";
55
import {
6-
unstable_createStaticRouter as createStaticRouter,
7-
unstable_StaticRouterProvider as StaticRouterProvider,
6+
createStaticRouter,
7+
StaticRouterProvider,
88
} from "react-router-dom/server";
99
import { routes } from "./App";
1010

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@
107107
},
108108
"filesize": {
109109
"packages/router/dist/router.umd.min.js": {
110-
"none": "36.5 kB"
110+
"none": "37.5 kB"
111111
},
112112
"packages/react-router/dist/react-router.production.min.js": {
113113
"none": "12.5 kB"
114114
},
115115
"packages/react-router/dist/umd/react-router.production.min.js": {
116-
"none": "14.5 kB"
116+
"none": "15 kB"
117117
},
118118
"packages/react-router-dom/dist/react-router-dom.production.min.js": {
119-
"none": "10.5 kB"
119+
"none": "11 kB"
120120
},
121121
"packages/react-router-dom/dist/umd/react-router-dom.production.min.js": {
122122
"none": "16.5 kB"

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

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

3+
## 6.6.0
4+
5+
### Patch Changes
6+
7+
- Updated dependencies:
8+
9+
10+
311
## 6.5.0
412

513
### Patch Changes

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-dom-v5-compat",
3-
"version": "6.5.0",
3+
"version": "6.6.0",
44
"description": "Migration path to React Router v6 from v4/5",
55
"keywords": [
66
"react",
@@ -24,7 +24,7 @@
2424
"types": "./dist/index.d.ts",
2525
"dependencies": {
2626
"history": "^5.3.0",
27-
"react-router": "6.5.0"
27+
"react-router": "6.6.0"
2828
},
2929
"peerDependencies": {
3030
"react": ">=16.8",

packages/react-router-dom/.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"__DEV__": true
88
},
99
"rules": {
10-
"strict": 0
10+
"strict": 0,
11+
"no-restricted-syntax": ["error", "LogicalExpression[operator='??']"]
1112
}
1213
}

packages/react-router-dom/CHANGELOG.md

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

3+
## 6.6.0
4+
5+
### Minor Changes
6+
7+
- Add `useBeforeUnload()` hook ([#9664](https://github.com/remix-run/react-router/pull/9664))
8+
- Remove `unstable_` prefix from `createStaticHandler`/`createStaticRouter`/`StaticRouterProvider` ([#9738](https://github.com/remix-run/react-router/pull/9738))
9+
10+
### Patch Changes
11+
12+
- Proper hydration of `Error` objects from `StaticRouterProvider` ([#9664](https://github.com/remix-run/react-router/pull/9664))
13+
- Support uppercase `<Form method>` and `useSubmit` method values ([#9664](https://github.com/remix-run/react-router/pull/9664))
14+
- Skip initial scroll restoration for SSR apps with `hydrationData` ([#9664](https://github.com/remix-run/react-router/pull/9664))
15+
- Fix `<button formmethod>` form submission overriddes ([#9664](https://github.com/remix-run/react-router/pull/9664))
16+
- Updated dependencies:
17+
- `@remix-run/[email protected]`
18+
19+
320
## 6.5.0
421

522
### Patch Changes

0 commit comments

Comments
 (0)