Skip to content

Commit 2d335f8

Browse files
Merge pull request #203 from reactjs/sync-84ad3308
Sync with reactjs.org @ 84ad330
2 parents a12ec9d + 626178d commit 2d335f8

12 files changed

+244
-165
lines changed

beta/src/pages/learn/add-react-to-a-website.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ return <button onClick={() => setLiked(true)}>Like</button>;
136136

137137
बहुत से लोग इसे React के साथ और अन्य लाइब्रेरी के साथ UI कोड लिखने के लिए परिचित और सहायक पाते हैं। आप अन्य प्रोजेक्ट्स में "आपके पूरे जावास्क्रिप्ट में फैला हुआ मार्कअप" देख सकते हैं!
138138

139-
> आप [इस ऑनलाइन कनवर्टर](https://babeljs.io/en/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=DwIwrgLhD2B2AEcDCAbAlgYwNYF4DeAFAJTw4B88EAFmgM4B0tAphAMoQCGETBe86WJgBMAXJQBOYJvAC-RGWQBQ8FfAAyaQYuAB6cFDhkgA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.4.3) का उपयोग करके HTML मार्कअप को JSX में बदलने के साथ खेल सकते हैं।
139+
> आप [इस ऑनलाइन कनवर्टर](https://babeljs.io/en/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=DwIwrgLhD2B2AEcDCAbAlgYwNYF4DeAFAJTw4B88EAFmgM4B0tAphAMoQCGETBe86WJgBMAXJQBOYJvAC-RGWQBQ8FfAAyaQYuAB6cFDhkgA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.17) का उपयोग करके HTML मार्कअप को JSX में बदलने के साथ खेल सकते हैं।
140140
141141
### JSX का प्रयास करें {/*try-jsx*/}
142142

beta/src/pages/learn/rendering-lists.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Say that you have a list of content.
3030
</ul>
3131
```
3232

33-
The only difference among those list items are their contents, their data. You will run into many situations where you need many of the same component using different data when building interfaces: from lists of comments to galleries of profile images. In these situations, you can store that data in JavaScript objects and arrays and use methods like [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) and [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) to render lists of components from them.
33+
The only difference among those list items is their contents, their data. You will often need to show several instances of the same component using different data when building interfaces: from lists of comments to galleries of profile images. In these situations, you can store that data in JavaScript objects and arrays and use methods like [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) and [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) to render lists of components from them.
3434

3535
Here’s a short example of how to generate a list of items from an array:
3636

content/blog/2022-03-08-react-18-upgrade-guide.md

+15
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ Finally, this API will continue to work for rendering e-mails:
126126

127127
For more information on the changes to server rendering APIs, see the working group post on [Upgrading to React 18 on the server](https://github.com/reactwg/react-18/discussions/22), a [deep dive on the new Suspense SSR Architecture](https://github.com/reactwg/react-18/discussions/37), and [Shaundai Person’s](https://twitter.com/shaundai) talk on [Streaming Server Rendering with Suspense](https://www.youtube.com/watch?v=pj5N-Khihgc) at React Conf 2021.
128128

129+
## Updates to TypeScript definitions
130+
131+
If your project uses TypeScript, you will need to update your `@types/react` and `@types/react-dom` dependencies to the latest versions. The new types are safer and catch issues that used to be ignored by the type checker. The most notable change is that the `children` prop now needs to be listed explicitly when defining props, for example:
132+
133+
```typescript{3}
134+
interface MyButtonProps {
135+
color: string;
136+
children?: React.ReactNode;
137+
}
138+
```
139+
140+
See the [React 18 typings pull request](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210) for a full list of type-only changes. It links to example fixes in library types so you can see how to adjust your code. You can use the [automated migration script](https://github.com/eps1lon/types-react-codemod) to help port your application code to the new and safer typings faster.
141+
142+
If you find a bug in the typings, please [file an issue](https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/new?category=issues-with-a-types-package) in the DefinitelyTyped repo.
143+
129144
## Automatic Batching {#automatic-batching}
130145

131146
React 18 adds out-of-the-box performance improvements by doing more batching by default. Batching is when React groups multiple state updates into a single re-render for better performance. Before React 18, we only batched updates inside React event handlers. Updates inside of promises, setTimeout, native event handlers, or any other event were not batched in React by default:

content/blog/2022-03-29-react-v18.md

+4
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ With Strict Mode in React 18, React will simulate unmounting and remounting the
220220

221221
`useId` is a new hook for generating unique IDs on both the client and server, while avoiding hydration mismatches. It is primarily useful for component libraries integrating with accessibility APIs that require unique IDs. This solves an issue that already exists in React 17 and below, but it's even more important in React 18 because of how the new streaming server renderer delivers HTML out-of-order. [See docs here](/docs/hooks-reference.html#useid).
222222

223+
> Note
224+
>
225+
> `useId` is **not** for generating [keys in a list](/docs/lists-and-keys.html#keys). Keys should be generated from your data.
226+
223227
#### useTransition {#usetransition}
224228

225229
`useTransition` and `startTransition` let you mark some state updates as not urgent. Other state updates are considered urgent by default. React will allow urgent state updates (for example, updating a text input) to interrupt non-urgent state updates (for example, rendering a list of search results). [See docs here](/docs/hooks-reference.html#usetransition)

content/community/conferences.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ Do you know of a local React.js conference? Add it here! (Please keep the list c
1212

1313
## Upcoming Conferences {#upcoming-conferences}
1414

15-
### React Live 2022 {#react-live-2022}
16-
April 1, 2022. Amsterdam, The Netherlands
17-
18-
[Website](https://www.reactlive.nl/) - [Twitter](https://twitter.com/reactlivenl)
19-
2015
### React Miami 2022 🌴 {#react-miami-2022}
2116
April 18 - 19, 2022. Miami, Florida
2217
[Website](https://www.reactmiami.com/)
@@ -60,6 +55,11 @@ September 1-2, 2022 - Remote event
6055
[Facebook](https://www.facebook.com/reactnativeeu/) -
6156
[Instagram](https://www.instagram.com/reactnative_eu/)
6257

58+
### React Finland 2022 {#react-finland-2022}
59+
September 12 - 16, 2022. In-person in Helsinki, Finland
60+
61+
[Website](https://react-finland.fi/) - [Twitter](https://twitter.com/ReactFinland) - [Schedule](https://react-finland.fi/schedule/) - [Speakers](https://react-finland.fi/speakers/)
62+
6363
### React India 2022 {#react-india-2022}
6464
September 22 - 24, 2022. In-person in Goa, India + remote (hybrid event)
6565

@@ -72,6 +72,11 @@ September 29 - October 1, 2022. In-person in Alicante, Spain + remote (hybrid ev
7272

7373
## Past Conferences {#past-conferences}
7474

75+
### React Live 2022 {#react-live-2022}
76+
April 1, 2022. Amsterdam, The Netherlands
77+
78+
[Website](https://www.reactlive.nl/) - [Twitter](https://twitter.com/reactlivenl)
79+
7580
### AgentConf 2022 {#agent-conf-2022}
7681

7782
January 27 - 30, 2022. In-person in Dornbirn and Lech Austria

content/docs/hooks-reference.md

+12
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ If you update a State Hook to the same value as the current state, React will ba
108108

109109
Note that React may still need to render that specific component again before bailing out. That shouldn't be a concern because React won't unnecessarily go "deeper" into the tree. If you're doing expensive calculations while rendering, you can optimize them with `useMemo`.
110110

111+
#### Batching of state updates {#batching-of-state-updates}
112+
113+
React may group several state updates into a single re-render to improve performance. Normally, this improves performance and shouldn't affect your application's behavior.
114+
115+
Before React 18, only updates inside React event handlers were batched. Starting with React 18, [batching is enabled for all updates by default](/blog/2022/03/08/react-18-upgrade-guide.html#automatic-batching). Note that React makes sure that updates from several *different* user-initiated events -- for example, clicking a button twice -- are always processed separately and do not get batched. This prevents logical mistakes.
116+
117+
In the rare case that you need to force the DOM update to be applied synchronously, you may wrap it in [`flushSync`](/docs/react-dom.html#flushsync). However, this can hurt performance so do this only where needed.
118+
111119
### `useEffect` {#useeffect}
112120

113121
```js
@@ -611,6 +619,10 @@ const id = useId();
611619

612620
`useId` is a hook for generating unique IDs that are stable across the server and client, while avoiding hydration mismatches.
613621

622+
> Note
623+
>
624+
> `useId` is **not** for generating [keys in a list](/docs/lists-and-keys.html#keys). Keys should be generated from your data.
625+
614626
For a basic example, pass the `id` directly to the elements that need it:
615627

616628
```js

content/docs/reference-react-component.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ setState(updater, [callback])
512512

513513
`setState()` enqueues changes to the component state and tells React that this component and its children need to be re-rendered with the updated state. This is the primary method you use to update the user interface in response to event handlers and server responses.
514514

515-
Think of `setState()` as a *request* rather than an immediate command to update the component. For better perceived performance, React may delay it, and then update several components in a single pass. React does not guarantee that the state changes are applied immediately.
515+
Think of `setState()` as a *request* rather than an immediate command to update the component. For better perceived performance, React may delay it, and then update several components in a single pass. In the rare case that you need to force the DOM update to be applied synchronously, you may wrap it in [`flushSync`](/docs/react-dom.html#flushsync), but this may hurt performance.
516516

517517
`setState()` does not always immediately update the component. It may batch or defer the update until later. This makes reading `this.state` right after calling `setState()` a potential pitfall. Instead, use `componentDidUpdate` or a `setState` callback (`setState(updater, callback)`), either of which are guaranteed to fire after the update has been applied. If you need to set the state based on the previous state, read about the `updater` argument below.
518518

content/docs/reference-react-dom-client.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ root.unmount();
7171
### `hydrateRoot()` {#hydrateroot}
7272

7373
```javascript
74-
hydrateRoot(element, container[, options])
74+
hydrateRoot(container, element[, options])
7575
```
7676

7777
Same as [`createRoot()`](#createroot), but is used to hydrate a container whose HTML contents were rendered by [`ReactDOMServer`](/docs/react-dom-server.html). React will attempt to attach event listeners to the existing markup.

0 commit comments

Comments
 (0)