Skip to content

Commit 121c425

Browse files
authored
Merge pull request #53 from reactjs/sync-af54fc87
Sync with react.dev @ af54fc8
2 parents c1fd568 + 8556289 commit 121c425

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

Diff for: src/content/learn/start-a-new-react-project.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ title: Пачаць новы React праект
2424
npx create-next-app@latest
2525
</TerminalBlock>
2626

27-
Для знаёмства з Next.js вы можаце азнаёміцца з іх [падручнікам па Next.js.](https://nextjs.org/learn/foundations/about-nextjs)
27+
Для знаёмства з Next.js вы можаце азнаёміцца з іх [курсам па Next.js.](https://nextjs.org/learn)
2828

2929
Next.js падтрымліваецца [Vercel](https://vercel.com/). Вы можаце [разгарнуць Next.js](https://nextjs.org/docs/app/building-your-application/deploying) на любым бессерверным хостынгу, Node.js хостынгу або на вашым уласным серверы. Next.js таксама падтрымлівае [экспарт у статычныя файлы](https://nextjs.org/docs/pages/building-your-application/deploying/static-exports), якія не патрабуюць хостынгу.
3030

Diff for: src/content/reference/react-dom/server/renderToNodeStream.md

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ On the client, call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to
4343

4444
* `reactNode`: A React node you want to render to HTML. For example, a JSX element like `<App />`.
4545

46+
* **optional** `options`: An object for server render.
47+
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as passed to [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters)
48+
4649
#### Returns {/*returns*/}
4750

4851
A [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) that outputs an HTML string.

Diff for: src/content/reference/react-dom/server/renderToStaticMarkup.md

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ It will produce non-interactive HTML output of your React components.
3535
#### Parameters {/*parameters*/}
3636

3737
* `reactNode`: A React node you want to render to HTML. For example, a JSX node like `<Page />`.
38+
* **optional** `options`: An object for server render.
39+
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page.
3840

3941
#### Returns {/*returns*/}
4042

Diff for: src/content/reference/react-dom/server/renderToStaticNodeStream.md

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ The stream will produce non-interactive HTML output of your React components.
3737

3838
* `reactNode`: A React node you want to render to HTML. For example, a JSX element like `<Page />`.
3939

40+
* **optional** `options`: An object for server render.
41+
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page.
42+
4043
#### Returns {/*returns*/}
4144

4245
A [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) that outputs an HTML string. The resulting HTML can't be hydrated on the client.

Diff for: src/content/reference/react-dom/server/renderToString.md

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ On the client, call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to
4242

4343
* `reactNode`: A React node you want to render to HTML. For example, a JSX node like `<App />`.
4444

45+
* **optional** `options`: An object for server render.
46+
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as passed to [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters)
47+
4548
#### Returns {/*returns*/}
4649

4750
An HTML string.

Diff for: src/content/reference/react/useId.md

+30
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,33 @@ input { margin: 5px; }
302302
```
303303
304304
</Sandpack>
305+
306+
---
307+
308+
### Using the same ID prefix on the client and the server {/*using-the-same-id-prefix-on-the-client-and-the-server*/}
309+
310+
If you [render multiple independent React apps on the same page](#specifying-a-shared-prefix-for-all-generated-ids), and some of these apps are server-rendered, make sure that the `identifierPrefix` you pass to the [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) call on the client side is the same as the `identifierPrefix` you pass to the [server APIs](/reference/react-dom/server) such as [`renderToPipeableStream`.](/reference/react-dom/server/renderToPipeableStream)
311+
312+
```js
313+
// Server
314+
import { renderToPipeableStream } from 'react-dom/server';
315+
316+
const { pipe } = renderToPipeableStream(
317+
<App />,
318+
{ identifierPrefix: 'react-app1' }
319+
);
320+
```
321+
322+
```js
323+
// Client
324+
import { hydrateRoot } from 'react-dom/client';
325+
326+
const domNode = document.getElementById('root');
327+
const root = hydrateRoot(
328+
domNode,
329+
reactNode,
330+
{ identifierPrefix: 'react-app1' }
331+
);
332+
```
333+
334+
You do not need to pass `identifierPrefix` if you only have one React app on the page.

0 commit comments

Comments
 (0)