Skip to content

Commit 9ac9de2

Browse files
authored
docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ ee8a829 (#1652)
2 parents b88c427 + 2e38291 commit 9ac9de2

File tree

12 files changed

+375
-130
lines changed

12 files changed

+375
-130
lines changed

.eslintrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"root": true,
33
"extends": "next/core-web-vitals",
44
"parser": "@typescript-eslint/parser",
5-
"plugins": ["@typescript-eslint"],
5+
"plugins": ["@typescript-eslint", "eslint-plugin-react-compiler"],
66
"rules": {
77
"no-unused-vars": "off",
8-
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_" }],
8+
"@typescript-eslint/no-unused-vars": ["error", {"varsIgnorePattern": "^_"}],
99
"react-hooks/exhaustive-deps": "error",
10-
"react/no-unknown-property": ["error", { "ignore": ["meta"] }]
10+
"react/no-unknown-property": ["error", {"ignore": ["meta"]}],
11+
"react-compiler/react-compiler": "error"
1112
},
1213
"env": {
1314
"node": true,

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"@docsearch/react": "^3.6.1",
2929
"@headlessui/react": "^1.7.0",
3030
"@radix-ui/react-context-menu": "^2.1.5",
31-
"babel-plugin-react-compiler": "0.0.0-experimental-696af53-20240625",
3231
"body-scroll-lock": "^3.1.3",
3332
"classnames": "^2.2.6",
3433
"date-fns": "^2.16.1",
@@ -62,13 +61,15 @@
6261
"asyncro": "^3.0.0",
6362
"autoprefixer": "^10.4.2",
6463
"babel-eslint": "10.x",
64+
"babel-plugin-react-compiler": "19.0.0-beta-e552027-20250112",
6565
"eslint": "7.x",
6666
"eslint-config-next": "12.0.3",
6767
"eslint-config-react-app": "^5.2.1",
6868
"eslint-plugin-flowtype": "4.x",
6969
"eslint-plugin-import": "2.x",
7070
"eslint-plugin-jsx-a11y": "6.x",
7171
"eslint-plugin-react": "7.x",
72+
"eslint-plugin-react-compiler": "^19.0.0-beta-e552027-20250112",
7273
"eslint-plugin-react-hooks": "^0.0.0-experimental-fabef7a6b-20221215",
7374
"fs-extra": "^9.0.1",
7475
"globby": "^11.0.1",
@@ -109,5 +110,6 @@
109110
"lint-staged": {
110111
"*.{js,ts,jsx,tsx,css}": "yarn prettier",
111112
"src/**/*.md": "yarn fix-headings"
112-
}
113+
},
114+
"packageManager": "yarn@1.22.22"
113115
}

src/components/Layout/Sidebar/SidebarRouteTree.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function CollapseWrapper({
3838
// Disable pointer events while animating.
3939
const isExpandedRef = useRef(isExpanded);
4040
if (typeof window !== 'undefined') {
41+
// eslint-disable-next-line react-compiler/react-compiler
4142
// eslint-disable-next-line react-hooks/rules-of-hooks
4243
useLayoutEffect(() => {
4344
const wasExpanded = isExpandedRef.current;

src/components/MDX/Sandpack/CustomPreset.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const CustomPreset = memo(function CustomPreset({
2828
const {activeFile} = sandpack;
2929
const lineCountRef = useRef<{[key: string]: number}>({});
3030
if (!lineCountRef.current[activeFile]) {
31+
// eslint-disable-next-line react-compiler/react-compiler
3132
lineCountRef.current[activeFile] = code.split('\n').length;
3233
}
3334
const lineCount = lineCountRef.current[activeFile];

src/components/MDX/Sandpack/Preview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*/
44

5+
// eslint-disable-next-line react-compiler/react-compiler
56
/* eslint-disable react-hooks/exhaustive-deps */
67
import {useRef, useState, useEffect, useMemo, useId} from 'react';
78
import {useSandpack, SandpackStack} from '@codesandbox/sandpack-react/unstyled';

src/components/MDX/Sandpack/SandpackRoot.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ function SandpackRoot(props: SandpackProps) {
7171
const codeSnippets = Children.toArray(children) as React.ReactElement[];
7272
const files = createFileMap(codeSnippets);
7373

74+
if ('/index.html' in files) {
75+
throw new Error(
76+
'You cannot use `index.html` file in sandboxes. ' +
77+
'Only `public/index.html` is respected by Sandpack and CodeSandbox (where forks are created).'
78+
);
79+
}
80+
7481
files['/src/styles.css'] = {
7582
code: [sandboxStyle, files['/src/styles.css']?.code ?? ''].join('\n\n'),
7683
hidden: !files['/src/styles.css']?.visible,

src/content/learn/add-react-to-an-existing-project.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ npm install react react-dom
5757

5858
<Sandpack>
5959

60-
```html index.html hidden
60+
```html public/index.html hidden
6161
<!DOCTYPE html>
6262
<html>
6363
<head><title>My app</title></head>
6464
<body>
6565
<!-- 你现有的页面内容(在这个例子中,它将被替换) -->
66+
<div id="root"></div>
6667
</body>
6768
</html>
6869
```
@@ -119,7 +120,7 @@ root.render(<h1>Hello, world</h1>);
119120

120121
<Sandpack>
121122

122-
```html index.html
123+
```html public/index.html
123124
<!DOCTYPE html>
124125
<html>
125126
<head><title>My app</title></head>

src/content/reference/react-dom/client/createRoot.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ root.render(<App />);
143143
144144
<Sandpack>
145145
146-
```html index.html
146+
```html public/index.html
147147
<!DOCTYPE html>
148148
<html>
149149
<head><title>My app</title></head>
@@ -375,7 +375,7 @@ You can use the `onUncaughtError` root option to display error dialogs:
375375
376376
<Sandpack>
377377
378-
```html index.html hidden
378+
```html public/index.html hidden
379379
<!DOCTYPE html>
380380
<html>
381381
<head>
@@ -606,7 +606,7 @@ You can use the `onCaughtError` root option to display error dialogs or filter k
606606
607607
<Sandpack>
608608
609-
```html index.html hidden
609+
```html public/index.html hidden
610610
<!DOCTYPE html>
611611
<html>
612612
<head>
@@ -885,7 +885,7 @@ You can use the `onRecoverableError` root option to display error dialogs:
885885
886886
<Sandpack>
887887
888-
```html index.html hidden
888+
```html public/index.html hidden
889889
<!DOCTYPE html>
890890
<html>
891891
<head>

src/content/reference/react-dom/client/hydrateRoot.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ You can use the `onUncaughtError` root option to display error dialogs:
408408
409409
<Sandpack>
410410
411-
```html index.html hidden
411+
```html public/index.html hidden
412412
<!DOCTYPE html>
413413
<html>
414414
<head>
@@ -643,7 +643,7 @@ You can use the `onCaughtError` root option to display error dialogs or filter k
643643
644644
<Sandpack>
645645
646-
```html index.html hidden
646+
```html public/index.html hidden
647647
<!DOCTYPE html>
648648
<html>
649649
<head>
@@ -924,7 +924,7 @@ You can use the `onRecoverableError` root option to display error dialogs for hy
924924
925925
<Sandpack>
926926
927-
```html index.html hidden
927+
```html public/index.html hidden
928928
<!DOCTYPE html>
929929
<html>
930930
<head>

src/content/reference/react-dom/createPortal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export default function ModalContent({ onClose }) {
252252
253253
<Sandpack>
254254
255-
```html index.html
255+
```html public/index.html
256256
<!DOCTYPE html>
257257
<html>
258258
<head><title>我的应用程序</title></head>

0 commit comments

Comments
 (0)