Skip to content

Commit 4be4233

Browse files
committed
Merge branch 'release-next'
2 parents 43cc1aa + e158bc1 commit 4be4233

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2750
-2977
lines changed

contributors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- bobziroll
2323
- BrianT1414
2424
- brockross
25+
- brookslybrand
2526
- brophdawg11
2627
- btav
2728
- bvangraafeiland
@@ -145,6 +146,7 @@
145146
- shamsup
146147
- shihanng
147148
- shivamsinghchahar
149+
- SimenB
148150
- SkayuX
149151
- souzasmatheus
150152
- srmagura
@@ -171,3 +173,4 @@
171173
- xavier-lc
172174
- xcsnowcity
173175
- yuleicul
176+
- jakkku

docs/components/form.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,16 @@ See also:
215215
- [`useActionData`][useactiondata]
216216
- [`useSubmit`][usesubmit]
217217

218+
## `preventScrollReset`
219+
220+
If you are using [`<ScrollRestoration>`][scrollrestoration], this lets you prevent the scroll position from being reset to the top of the window when the form action redirects to a new location.
221+
222+
```tsx
223+
<Form method="post" preventScrollReset={true} />
224+
```
225+
226+
See also: [`<Link preventScrollReset>`][link-preventscrollreset]
227+
218228
# Examples
219229

220230
TODO: More examples
@@ -318,3 +328,5 @@ You can access those values from the `request.url`
318328
[formvalidation]: https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation
319329
[indexsearchparam]: ../guides/index-search-param
320330
[pickingarouter]: ../routers/picking-a-router
331+
[scrollrestoration]: ./scroll-restoration
332+
[link-preventscrollreset]: ./link#preventscrollreset

docs/components/scroll-restoration.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ Or you may want to only use the pathname for some paths, and use the normal beha
8383

8484
## Preventing Scroll Reset
8585

86-
When navigation creates new scroll keys, the scroll position is reset to the top of the page. You can prevent the "scroll to top" behavior from your links:
86+
When navigation creates new scroll keys, the scroll position is reset to the top of the page. You can prevent the "scroll to top" behavior from your links and forms:
8787

8888
```tsx
8989
<Link preventScrollReset={true} />
90+
<Form preventScrollReset={true} />
9091
```
9192

92-
See also: [`<Link preventScrollReset>`][preventscrollreset]
93+
See also: [`<Link preventScrollReset>`][preventscrollreset], [`<Form preventScrollReset>`][form-preventscrollreset]
9394

9495
## Scroll Flashing
9596

@@ -99,4 +100,5 @@ Server Rendering frameworks can prevent scroll flashing because they can send a
99100

100101
[remix]: https://remix.run
101102
[preventscrollreset]: ../components/link#preventscrollreset
103+
[form-preventscrollreset]: ../components/form#preventscrollreset
102104
[pickingarouter]: ../routers/picking-a-router

package.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"packages/react-router-dom-v5-compat",
99
"packages/react-router-native",
1010
"packages/router"
11-
],
12-
"nohoist": [
13-
"**/react-native",
14-
"**/react-native/**"
1511
]
1612
},
1713
"scripts": {
@@ -59,7 +55,7 @@
5955
"@rollup/plugin-typescript": "^8.3.2",
6056
"@testing-library/jest-dom": "5.16.3",
6157
"@testing-library/react": "^13.3.0",
62-
"@types/jest": "26.x",
58+
"@types/jest": "29.x",
6359
"@types/jsdom": "16.2.14",
6460
"@types/jsonfile": "^6.0.1",
6561
"@types/react": "^18.0.15",
@@ -71,7 +67,7 @@
7167
"@typescript-eslint/parser": "^4.28.3",
7268
"abort-controller": "^3.0.0",
7369
"babel-eslint": "^10.1.0",
74-
"babel-jest": "^26.6.3",
70+
"babel-jest": "^29.0.3",
7571
"babel-plugin-dev-expression": "^0.2.2",
7672
"chalk": "^4.1.1",
7773
"cheerio": "^1.0.0-rc.10",
@@ -85,9 +81,9 @@
8581
"eslint-plugin-react-hooks": "next",
8682
"fs-extra": "^10.1.0",
8783
"history": "^5.3.0",
88-
"jest": "^26.6.3",
84+
"jest": "^29.0.3",
85+
"jest-environment-jsdom": "^29.0.3",
8986
"jsonfile": "^6.1.0",
90-
"metro-react-native-babel-preset": "^0.57.0",
9187
"patch-package": "^6.4.7",
9288
"prettier": "^2.5.1",
9389
"prompt-confirm": "^2.0.4",
@@ -100,7 +96,6 @@
10096
"rollup-plugin-prettier": "^2.2.2",
10197
"rollup-plugin-terser": "^7.0.2",
10298
"semver": "^7.3.5",
103-
"ts-jest": "^26.5.6",
10499
"type-fest": "^2.13.0",
105100
"typescript": "^4.7.3"
106101
},
@@ -109,7 +104,7 @@
109104
},
110105
"filesize": {
111106
"packages/router/dist/router.umd.min.js": {
112-
"none": "41 kB"
107+
"none": "41.5 kB"
113108
},
114109
"packages/react-router/dist/react-router.production.min.js": {
115110
"none": "13 kB"
@@ -121,7 +116,7 @@
121116
"none": "11.5 kB"
122117
},
123118
"packages/react-router-dom/dist/umd/react-router-dom.production.min.js": {
124-
"none": "17 kB"
119+
"none": "17.5 kB"
125120
}
126121
}
127122
}

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.8.0
4+
5+
### Patch Changes
6+
7+
- Fix SSR `useLayoutEffect` `console.error` when using `CompatRouter` ([#9820](https://github.com/remix-run/react-router/pull/9820))
8+
- Updated dependencies:
9+
10+
11+
312
## 6.7.0
413

514
### Patch Changes
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @jest-environment node
3+
*/
4+
import * as React from "react";
5+
import * as ReactDOMServer from "react-dom/server";
6+
import { act } from "react-dom/test-utils";
7+
import { CompatRouter, Routes } from "../index";
8+
9+
// Have to mock react-router-dom to have a comparable API to v5, otherwise it will
10+
// be using v6's API and fail
11+
jest.mock("react-router-dom", () => ({
12+
useHistory: () => ({ location: "/" }),
13+
}));
14+
15+
describe("CompatRouter", () => {
16+
it("should not warn about useLayoutEffect when server side rendering", () => {
17+
const consoleErrorSpy = jest.spyOn(console, "error");
18+
19+
act(() => {
20+
ReactDOMServer.renderToStaticMarkup(
21+
<CompatRouter>
22+
<Routes />
23+
</CompatRouter>
24+
);
25+
});
26+
27+
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
28+
consoleErrorSpy.mockRestore();
29+
});
30+
});

packages/react-router-dom-v5-compat/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
testEnvironment: "jsdom",
23
testMatch: ["**/__tests__/*-test.[jt]s?(x)"],
34
transform: {
45
"\\.[jt]sx?$": "./jest-transformer.js",
@@ -9,6 +10,13 @@ module.exports = {
910
setupFiles: ["./__tests__/setup.ts"],
1011
moduleNameMapper: {
1112
"^@remix-run/router$": "<rootDir>/../router/index.ts",
13+
"^@remix-run/web-blob$": require.resolve("@remix-run/web-blob"),
14+
"^@remix-run/web-fetch$": require.resolve("@remix-run/web-fetch"),
15+
"^@remix-run/web-form-data$": require.resolve("@remix-run/web-form-data"),
16+
"^@remix-run/web-stream$": require.resolve("@remix-run/web-stream"),
17+
"^@web3-storage/multipart-parser$": require.resolve(
18+
"@web3-storage/multipart-parser"
19+
),
1220
"^react-router$": "<rootDir>/../react-router/index.ts",
1321
"^react-router-dom-v5-compat$": "<rootDir>/index.ts",
1422
},

packages/react-router-dom-v5-compat/lib/components.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,25 @@ export function CompatRoute(props: any) {
2323
);
2424
}
2525

26+
// Copied with 💜 from https://github.com/bvaughn/react-resizable-panels/blob/main/packages/react-resizable-panels/src/hooks/useIsomorphicEffect.ts
27+
const canUseEffectHooks = !!(
28+
typeof window !== "undefined" &&
29+
typeof window.document !== "undefined" &&
30+
typeof window.document.createElement !== "undefined"
31+
);
32+
33+
const useIsomorphicLayoutEffect = canUseEffectHooks
34+
? React.useLayoutEffect
35+
: () => {};
36+
2637
export function CompatRouter({ children }: { children: React.ReactNode }) {
2738
let history = useHistory();
2839
let [state, setState] = React.useState(() => ({
2940
location: history.location,
3041
action: history.action,
3142
}));
3243

33-
React.useLayoutEffect(() => {
44+
useIsomorphicLayoutEffect(() => {
3445
history.listen((location: Location, action: Action) =>
3546
setState({ location, action })
3647
);

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.7.0",
3+
"version": "6.8.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.7.0"
27+
"react-router": "6.8.0"
2828
},
2929
"peerDependencies": {
3030
"react": ">=16.8",

packages/react-router-dom/CHANGELOG.md

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

3+
## 6.8.0
4+
5+
### Minor Changes
6+
7+
- Support absolute URLs in `<Link to>`. If the URL is for the current origin, it will still do a client-side navigation. If the URL is for a different origin then it will do a fresh document request for the new origin. ([#9900](https://github.com/remix-run/react-router/pull/9900))
8+
9+
```tsx
10+
<Link to="https://neworigin.com/some/path"> {/* Document request */}
11+
<Link to="//neworigin.com/some/path"> {/* Document request */}
12+
<Link to="https://www.currentorigin.com/path"> {/* Client-side navigation */}
13+
```
14+
15+
### Patch Changes
16+
17+
- Fix bug with search params removal via `useSearchParams` ([#9969](https://github.com/remix-run/react-router/pull/9969))
18+
- Respect `preventScrollReset` on `<fetcher.Form>` ([#9963](https://github.com/remix-run/react-router/pull/9963))
19+
- Fix navigation for hash routers on manual URL changes ([#9980](https://github.com/remix-run/react-router/pull/9980))
20+
- Use `pagehide` instead of `beforeunload` for `<ScrollRestoration>`. This has better cross-browser support, specifically on Mobile Safari. ([#9945](https://github.com/remix-run/react-router/pull/9945))
21+
- Updated dependencies:
22+
- `@remix-run/[email protected]`
23+
24+
325
## 6.7.0
426

527
### Minor Changes

0 commit comments

Comments
 (0)