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
Copy file name to clipboardExpand all lines: src/content/blog/2024/04/01/react-19.md
+18-11Lines changed: 18 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -253,19 +253,22 @@ The `use` API can only be called in render, similar to hooks. Unlike hooks, `use
253
253
254
254
For more information, see the docs for [`use`](/reference/react/use).
255
255
256
-
### React Server Components (RSC) {/*new-feature-server-components*/}
256
+
257
+
### React Server Components {/*react-server-components*/}
258
+
259
+
### Server Components {/*server-components*/}
257
260
258
261
Server Components are a new option that allows rendering components ahead of time, before bundling, in an environment separate from your application (the "server"). They can run once at build time, or can be run for each request to a web server.
259
262
260
-
Today we're releasing React Server Components as semver stable in React 19. This means libraries that ship Server Components and Server Actions can target React 19 as a peer dependency for use in frameworks that support the [Full-stack React Architecture](/learn/start-a-new-react-project#which-features-make-up-the-react-teams-full-stack-architecture-vision).
263
+
Today we're releasing React Server Components as semver stable in React 19. TODO: re-write This means libraries that ship Server Components and Server Actions can target React 19 as a peer dependency for use in frameworks that support the [Full-stack React Architecture](/learn/start-a-new-react-project#which-features-make-up-the-react-teams-full-stack-architecture-vision).
261
264
262
-
For more, see the docs for [React Server Components](/reference/full-stack/server-components).
265
+
For more, see the docs for [React Server Components](/reference/rsc/server-components).
263
266
264
267
<DeepDive>
265
268
266
269
#### How do I use Server Components? {/*how-do-i-use-server-components*/}
267
270
268
-
We first announced React Server Components (RSC) in a [demo in December 2020](https://legacy.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html). In 2022, we merged the [RFC for React Server Components](https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md) and the [RFC for React Server Module Conventions](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md) and partnered with Next.js for the first implementation in the Next.js 13 App Router beta. We worked with the Next.js team to implement Server Components via the stable Canary channel, and Server Components shipped as the default in Next.js 14.
271
+
We first announced React Server Components in a [demo in December 2020](https://legacy.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html). In 2022, we merged the [RFC for React Server Components](https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md) and the [RFC for React Server Module Conventions](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md) and partnered with Next.js for the first implementation in the Next.js 13 App Router beta. We worked with the Next.js team to implement Server Components via the stable Canary channel, and Server Components shipped as the default in Next.js 14.
269
272
270
273
We will continue working with bundlers and framework authors to expand support for React Server Components.
271
274
@@ -277,15 +280,15 @@ TODO:
277
280
278
281
</DeepDive>
279
282
280
-
### React Server Actions (RSA) {/*react-server-actions-rsa*/}
283
+
### Server Actions {/*server-actions*/}
281
284
282
285
Server Actions allow Client Components to call async functions executed on the server.
283
286
284
287
When a Server Action is defined with the `"use server"` directive, your framework will automatically create a reference to the server function, and pass that reference to the Client Component. When that function is called on the client, React will send a request to the server to execute the function, and return the result.
285
288
286
289
Server Actions can be created in Server Components and passed as props to Client Components, or they can be imported and used in Client Components.
287
290
288
-
For more, see the docs for [React Server Actions](/reference/full-stack/server-actions).
291
+
For more, see the docs for [React Server Actions](/reference/rsc/server-actions).
289
292
290
293
<DeepDive>
291
294
@@ -409,12 +412,12 @@ In HTML, document metadata tags like `<title>` and `<meta>` are reserved for pla
409
412
In React 19, we're adding support for rendering document metadata tags in components natively:
410
413
411
414
```js {5,6}
412
-
function Component() {
415
+
function BlogPost({post}) {
413
416
return (
414
417
<div>
415
-
<p>Hello World</p>
416
-
<title>Hello World</title>
417
-
<meta name="keywords" content="React 19"/>
418
+
<p>{post.title}</p>
419
+
<title>{post.title}</title>
420
+
<meta name="keywords" content={post.keywords} />
418
421
</div>
419
422
);
420
423
}
@@ -449,7 +452,11 @@ To maintain compatibility with HTML and optimize performance, React will dedupe
449
452
450
453
### Improved hydration for third-party scripts {/*improved-hydration-for-third-party-scripts*/}
451
454
452
-
We've improved hydration to account for third-party scripts and browser extensions. TODO: explain how.
455
+
We've improved hydration to account for third-party scripts and browser extensions.
456
+
457
+
When hydrating, if an element that renders on the client doesn't match the element found in the HTML from the server, React will force a client re-render to fix up the content. Previously, if an element was inserted by third-party scripts or browser extensions, it would trigger a mismatch error and client render.
458
+
459
+
In React 19 unexpected tags in the `<head>` and `<body>` will be skipped over, avoiding the mismatch errors. If React needs to re-render the entire document due to an unrelated hydration mismatch, it will leave in place stylesheets inserted by third-party scripts and browser extensions.
0 commit comments