Skip to content

Commit

Permalink
docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ 589a1d3
Browse files Browse the repository at this point in the history
  • Loading branch information
loveloki authored Oct 1, 2024
2 parents 38d326c + 27ca116 commit d0bb54b
Show file tree
Hide file tree
Showing 18 changed files with 1,162 additions and 1,110 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
},
"dependencies": {
"@codesandbox/sandpack-react": "2.13.5",
"@docsearch/css": "3.0.0-alpha.41",
"@docsearch/react": "3.0.0-alpha.41",
"@docsearch/css": "^3.6.1",
"@docsearch/react": "^3.6.1",
"@headlessui/react": "^1.7.0",
"@radix-ui/react-context-menu": "^2.1.5",
"body-scroll-lock": "^3.1.3",
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function Preview({
/**
* The spinner component transition might be longer than
* the bundler loading, so we only show the spinner if
* it takes more than 1s to load the bundler.
* it takes more than 500s to load the bundler.
*/
timeout = setTimeout(() => {
setShowLoading(true);
Expand Down
12 changes: 11 additions & 1 deletion src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ export function Search({
onOpen,
onClose,
searchParameters = {
hitsPerPage: 5,
hitsPerPage: 30,
attributesToHighlight: [
'hierarchy.lvl0',
'hierarchy.lvl1',
'hierarchy.lvl2',
'hierarchy.lvl3',
'hierarchy.lvl4',
'hierarchy.lvl5',
'hierarchy.lvl6',
'content',
],
},
}: SearchProps) {
useDocSearchKeyboardEvents({isOpen, onOpen, onClose});
Expand Down
4 changes: 2 additions & 2 deletions src/content/blog/2024/04/25/react-19-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ npm install react-shallow-renderer --save-dev

##### Please reconsider shallow rendering {/*please-reconsider-shallow-rendering*/}

Shallow rendering depends on React internals and can block you from future upgrades. We recommend migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) or [@testing-library/react-native](https://callstack.github.io/react-native-testing-library/docs/getting-started).
Shallow rendering depends on React internals and can block you from future upgrades. We recommend migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) or [@testing-library/react-native](https://testing-library.com/docs/react-native-testing-library/intro).

</Note>

Expand Down Expand Up @@ -524,7 +524,7 @@ We are deprecating `react-test-renderer` because it implements its own renderer

The test renderer was created before there were more viable testing strategies available like [React Testing Library](https://testing-library.com), and we now recommend using a modern testing library instead.

In React 19, `react-test-renderer` logs a deprecation warning, and has switched to concurrent rendering. We recommend migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) or [@testing-library/react-native](https://callstack.github.io/react-native-testing-library/docs/getting-started) for a modern and well supported testing experience.
In React 19, `react-test-renderer` logs a deprecation warning, and has switched to concurrent rendering. We recommend migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) or [@testing-library/react-native](https://testing-library.com/docs/react-native-testing-library/intro) for a modern and well supported testing experience.

## Notable changes {/*notable-changes*/}

Expand Down
10 changes: 10 additions & 0 deletions src/content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ October 18, 2024. In-person in Brussels, Belgium (hybrid event)

[Website](https://www.react.brussels/) - [Twitter](https://x.com/BrusselsReact)

### reactjsday 2024 {/*reactjsday-2024*/}
October 25, 2024. In-person in Verona, Italy + online (hybrid event)

[Website](https://2024.reactjsday.it/) - [Twitter](https://x.com/reactjsday) - [Facebook](https://www.facebook.com/GrUSP/) - [YouTube](https://www.youtube.com/c/grusp)

### React Advanced London 2024 {/*react-advanced-london-2024*/}
October 25 & 28, 2024. In-person in London, UK + online (hybrid event)

[Website](https://reactadvanced.com/) - [Twitter](https://x.com/reactadvanced)

### React Native London Conf 2024 {/*react-native-london-2024*/}
November 14 & 15, 2024. In-person in London, UK

[Website](https://reactnativelondon.co.uk/) - [Twitter](https://x.com/RNLConf)

### React Summit US 2024 {/*react-summit-us-2024*/}
November 19 & 22, 2024. In-person in New York, USA + online (hybrid event)

Expand Down
3 changes: 3 additions & 0 deletions src/content/community/meetups.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
## Italy {/*italy*/}
* [Milan](https://www.meetup.com/React-JS-Milano/)

## Japan {/*japan*/}
* [Osaka](https://react-osaka.connpass.com/)

## Kenya {/*kenya*/}
* [Nairobi - Reactdevske](https://kommunity.com/reactjs-developer-community-kenya-reactdevske)

Expand Down
28 changes: 14 additions & 14 deletions src/content/learn/manipulating-the-dom-with-refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,35 +126,35 @@ export default function CatFriends() {
<>
<nav>
<button onClick={handleScrollToFirstCat}>
Tom
Neo
</button>
<button onClick={handleScrollToSecondCat}>
Maru
Millie
</button>
<button onClick={handleScrollToThirdCat}>
Jellylorum
Bella
</button>
</nav>
<div>
<ul>
<li>
<img
src="https://placekitten.com/g/200/200"
alt="Tom"
src="https://placecats.com/neo/300/200"
alt="Neo"
ref={firstCatRef}
/>
</li>
<li>
<img
src="https://placekitten.com/g/300/200"
alt="Maru"
src="https://placecats.com/millie/200/200"
alt="Millie"
ref={secondCatRef}
/>
</li>
<li>
<img
src="https://placekitten.com/g/250/200"
alt="Jellylorum"
src="https://placecats.com/bella/199/200"
alt="Bella"
ref={thirdCatRef}
/>
</li>
Expand Down Expand Up @@ -247,9 +247,9 @@ export default function CatFriends() {
return (
<>
<nav>
<button onClick={() => scrollToCat(catList[0])}>Tom</button>
<button onClick={() => scrollToCat(catList[5])}>Maru</button>
<button onClick={() => scrollToCat(catList[9])}>Jellylorum</button>
<button onClick={() => scrollToCat(catList[0])}>Neo</button>
<button onClick={() => scrollToCat(catList[5])}>Millie</button>
<button onClick={() => scrollToCat(catList[9])}>Bella</button>
</nav>
<div>
<ul>
Expand Down Expand Up @@ -950,7 +950,7 @@ const catList = [];
for (let i = 0; i < 10; i++) {
catList.push({
id: i,
imageUrl: 'https://placekitten.com/250/200?image=' + i
imageUrl: 'https://loremflickr.com/250/200/cat?lock=' + i
});
}

Expand Down Expand Up @@ -1067,7 +1067,7 @@ const catList = [];
for (let i = 0; i < 10; i++) {
catList.push({
id: i,
imageUrl: 'https://placekitten.com/250/200?image=' + i
imageUrl: 'https://loremflickr.com/250/200/cat?lock=' + i
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/thinking-in-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ props 和 state 是不同的,但它们可以共同工作。父组件将经常
* `ProductTable` 需要基于 state (搜索文本和复选框值) 过滤产品列表。
* `SearchBar` 需要展示 state (搜索文本和复选框值)。
2. **寻找它们的父组件**:它们的第一个共同父组件为 `FilterableProductTable`
3. **决定 state 放置的地方**我们将放置过滤文本和勾选 state 的值于 `FilterableProductTable`
3. **决定 state 放置的地方**我们将过滤文本和勾选 state 的值放置于 `FilterableProductTable`

所以 state 将被放置在 `FilterableProductTable`

Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/tutorial-tic-tac-toe.md
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ export default function Board() {
<Note>
JavaScript 支持闭包,这意味着内部函数(例如 `handleClick`)可以访问外部函数(例如 `Board`)中定义的变量和函数。`handleClick` 函数可以读取 `squares` state 并调用 `setSquares` 方法,因为它们都是在 `Board` 函数内部定义的。
JavaScript 支持 [闭包](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Closures),这意味着内部函数(例如 `handleClick`)可以访问外部函数(例如 `Board`)中定义的变量和函数。`handleClick` 函数可以读取 `squares` state 并调用 `setSquares` 方法,因为它们都是在 `Board` 函数内部定义的。
</Note>
Expand Down
2 changes: 2 additions & 0 deletions src/content/learn/updating-objects-in-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ position.x = 5;

```js
import { useState } from 'react';

export default function MovingDot() {
const [position, setPosition] = useState({
x: 0,
Expand Down Expand Up @@ -131,6 +132,7 @@ onPointerMove={e => {

```js
import { useState } from 'react';

export default function MovingDot() {
const [position, setPosition] = useState({
x: 0,
Expand Down
8 changes: 4 additions & 4 deletions src/content/reference/react/act.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ To test the render output of a component, wrap the render inside `act()`:

```js {10,12}
import {act} from 'react';
import ReactDOM from 'react-dom/client';
import ReactDOMClient from 'react-dom/client';
import Counter from './Counter';

it('can render and update a counter', async () => {
Expand All @@ -99,7 +99,7 @@ it('can render and update a counter', async () => {

// ✅ Render the component inside act().
await act(() => {
ReactDOM.createRoot(container).render(<Counter />);
ReactDOMClient.createRoot(container).render(<Counter />);
});

const button = container.querySelector('button');
Expand All @@ -119,7 +119,7 @@ To test events, wrap the event dispatch inside `act()`:

```js {14,16}
import {act} from 'react';
import ReactDOM from 'react-dom/client';
import ReactDOMClient from 'react-dom/client';
import Counter from './Counter';

it.only('can render and update a counter', async () => {
Expand Down Expand Up @@ -174,4 +174,4 @@ global.IS_REACT_ACT_ENVIRONMENT=true

In testing frameworks like [React Testing Library](https://testing-library.com/docs/react-testing-library/intro), `IS_REACT_ACT_ENVIRONMENT` is already set for you.

</Note>
</Note>
18 changes: 9 additions & 9 deletions src/content/reference/react/useRef.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,33 +327,33 @@ export default function CatFriends() {
<>
<nav>
<button onClick={() => scrollToIndex(0)}>
Tom
Neo
</button>
<button onClick={() => scrollToIndex(1)}>
Maru
Millie
</button>
<button onClick={() => scrollToIndex(2)}>
Jellylorum
Bella
</button>
</nav>
<div>
<ul ref={listRef}>
<li>
<img
src="https://placekitten.com/g/200/200"
alt="Tom"
src="https://placecats.com/neo/300/200"
alt="Neo"
/>
</li>
<li>
<img
src="https://placekitten.com/g/300/200"
alt="Maru"
src="https://placecats.com/millie/200/200"
alt="Millie"
/>
</li>
<li>
<img
src="https://placekitten.com/g/250/200"
alt="Jellylorum"
src="https://placecats.com/bella/199/200"
alt="Bella"
/>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/rsc/server-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import {createNoteAction} from './actions';
function EmptyNote() {
console.log(createNoteAction);
// {$$typeof: Symbol.for("react.server.reference"), $$id: 'createNoteAction'}
<button onClick={createNoteAction} />
return <button onClick={createNoteAction} />
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function ExpenseForm() {

```js {2}
function ProductDetailPage({ product }) {
document.window.title = product.title; // 🔴 错误的:改变 DOM
document.title = product.title; // 🔴 错误的:改变 DOM
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports.siteConfig = {
twitterUrl: 'https://twitter.com/reactjs',
algolia: {
appId: '1FCF9AYYAT',
apiKey: 'e8451218980a351815563de007648b00',
apiKey: '1b7ad4e1c89e645e351e59d40544eda1',
indexName: 'beta-react',
},
};
3 changes: 2 additions & 1 deletion src/utils/finishedTranslations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const finishedTranslations = [
'es',
'fr',
'ja',
'tr'
'tr',
'ko'
];
2 changes: 1 addition & 1 deletion src/utils/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.generateRssFeed = function () {
const files = filesByOldest.reverse();

for (const filePath of files) {
const id = filePath.split('/').slice(-1).join('');
const id = path.basename(filePath);
if (id !== 'index.md') {
const content = fs.readFileSync(filePath, 'utf-8');
const {data} = matter(content);
Expand Down
Loading

0 comments on commit d0bb54b

Please sign in to comment.