You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix grammar (#4502)
* Fix grammar
* Update rendering-lists.md
Co-authored-by: dan <[email protected]>
* docs: Add React Finland 2022 (#4544)
* Update conferences.md (#4546)
* fix babel url version (#4549)
Co-authored-by: David <[email protected]>
* Fix params order for hydrateRoot reference (#4552)
* Override sharp version (#4554)
* Document useId is not for keys (#4557)
* Edits for ReactDOMServer API (#4558)
* Edits for ReactDOMServer API
* Move note below example
* No destructure
* Rm hr
* Add onError
* Drop SEO
* Update reference-react-dom-server.md
* Clarify renderToString etc usage
* Add more details on batching (#4559)
* Add more details on batching
* Use a generic example
* renderToReadableStream: Ensure same var name is used in `onError` (#4562)
* Mention TypeScript in the upgrade post (#4567)
* Mention TypeScript in the upgrade post
* Add a link
* fix typo "sever" on reference-react-dom-server.md (#4570)
* resolve merge conflicts
Co-authored-by: Jeongwoo Park <[email protected]>
Co-authored-by: dan <[email protected]>
Co-authored-by: Juho Vepsäläinen <[email protected]>
Co-authored-by: Strek <[email protected]>
Co-authored-by: DavidKessel <[email protected]>
Co-authored-by: David <[email protected]>
Co-authored-by: Marco Antonio Ghiani <[email protected]>
Co-authored-by: Sebastian Silbermann <[email protected]>
Co-authored-by: Antony Budianto <[email protected]>
Co-authored-by: Rainer Martínez Fraga <[email protected]>
Estos dos fragmentos de código son equivalentes. JSX es una sintaxis popular para describir marcado en JavaScript. Muchas personas lo encuentran familiar y útil para escribir código de UI--tanto con React como con otras bibliotecas. ¡Puede que veas «marcado esparcido por tu JavaScript» en otros proyectos!
138
138
139
-
> Puedes interactuar con la transformación de marcado HTML en JSX usando este [convertir en línea](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).
139
+
> Puedes interactuar con la transformación de marcado HTML en JSX usando este [convertir en línea](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).
Copy file name to clipboardExpand all lines: beta/src/pages/learn/rendering-lists.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Say that you have a list of content.
30
30
</ul>
31
31
```
32
32
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.
34
34
35
35
Here’s a short example of how to generate a list of items from an array:
Copy file name to clipboardExpand all lines: content/blog/2022-03-08-react-18-upgrade-guide.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,6 +126,21 @@ Finally, this API will continue to work for rendering e-mails:
126
126
127
127
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.
128
128
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
+
129
144
## Automatic Batching {#automatic-batching}
130
145
131
146
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:
Copy file name to clipboardExpand all lines: content/blog/2022-03-29-react-v18.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -220,6 +220,10 @@ With Strict Mode in React 18, React will simulate unmounting and remounting the
220
220
221
221
`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).
222
222
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
+
223
227
#### useTransition {#usetransition}
224
228
225
229
`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)
Copy file name to clipboardExpand all lines: content/docs/hooks-reference.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,14 @@ Si se actualiza un Hook de estado con el mismo valor que el estado actual, React
108
108
109
109
Recuerda que React puede necesitar renderizar de nuevo ese componente en específico antes de evitarlo. Esto no debería ser un problema ya que React no irá innecesariamente "más profundo" en el árbol. Si estás realizando cálculos costosos mientras renderizas, puedes optimizarlos con `useMemo`.
110
110
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
+
111
119
### `useEffect` {#useeffect}
112
120
113
121
```js
@@ -612,6 +620,10 @@ const id = useId();
612
620
613
621
`useId` is a hook for generating unique IDs that are stable across the server and client, while avoiding hydration mismatches.
614
622
623
+
> Note
624
+
>
625
+
> `useId` is **not** for generating [keys in a list](/docs/lists-and-keys.html#keys). Keys should be generated from your data.
626
+
615
627
For a basic example, pass the `id` directly to the elements that need it:
Copy file name to clipboardExpand all lines: content/docs/reference-react-component.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -507,7 +507,7 @@ setState(updater, [callback])
507
507
508
508
`setState()` hace cambios al estado del componente y le dice a React que este componente y sus elementos secundarios deben volverse a procesar con el estado actualizado. Este es el método principal que utiliza para actualizar la interfaz de usuario en respuesta a los manejadores de eventos y las respuestas del servidor.
509
509
510
-
Considera `setState()` como una *solicitud* en lugar de un comando para actualizar el componente. Para un mejor rendimiento percibido, React puede retrasarlo, y luego actualizar varios componentes en una sola pasada. React no garantiza que los cambios de estado se apliquen de inmediato.
510
+
Considera `setState()` como una *solicitud* en lugar de un comando para actualizar el componente. Para que se perciba un mejor rendimiento, React puede retrasarlo, y luego actualizar varios componentes en una sola pasada. En el caso inusual que necesites forzar a que la actualización del DOM se aplique de manera síncrona, puedes envolverlo en [`flushSync`](/docs/react-dom.html#flushsync), pero esto puede afectar el rendimiento.
511
511
512
512
`setState()` no siempre actualiza inmediatamente el componente. Puede procesar por lotes o diferir la actualización hasta más tarde. Esto hace que leer `this.state` después de llamar a `setState()` sea una trampa potencial. En su lugar, usa `componentDidUpdate` o un callback `setState` (`setState(updater, callback)`), se garantiza que cualquiera de los dos se activará una vez la actualización haya sido aplicada. Si necesitas establecer el estado en función del estado anterior, lee a continuación sobre el argumento `updater`.
Copy file name to clipboardExpand all lines: content/docs/reference-react-dom-client.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ root.unmount();
71
71
### `hydrateRoot()` {#hydrateroot}
72
72
73
73
```javascript
74
-
hydrateRoot(element, container[, options])
74
+
hydrateRoot(container, element[, options])
75
75
```
76
76
77
77
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