Skip to content

Translate renderToStaticNodeStream.md to pt-br #893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/content/reference/react-dom/server/renderToStaticNodeStream.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: renderToStaticNodeStream

<Intro>

`renderToStaticNodeStream` renders a non-interactive React tree to a [Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams)
`renderToStaticNodeStream` renderiza uma árvore React não interativa para um [Node.js Readable Stream.](https://nodejs.org/api/stream.html#readable-streams)

```js
const stream = renderToStaticNodeStream(reactNode, options?)
Expand All @@ -20,7 +20,7 @@ const stream = renderToStaticNodeStream(reactNode, options?)

### `renderToStaticNodeStream(reactNode, options?)` {/*rendertostaticnodestream*/}

On the server, call `renderToStaticNodeStream` to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams).
No servidor, chame `renderToStaticNodeStream` para obter um [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams).

```js
import { renderToStaticNodeStream } from 'react-dom/server';
Expand All @@ -29,55 +29,55 @@ const stream = renderToStaticNodeStream(<Page />);
stream.pipe(response);
```

[See more examples below.](#usage)
[Veja mais exemplos abaixo.](#usage)

The stream will produce non-interactive HTML output of your React components.
O stream produzirá uma saída HTML não interativa de seus componentes React.

#### Parameters {/*parameters*/}

* `reactNode`: A React node you want to render to HTML. For example, a JSX element like `<Page />`.
* `reactNode`: Um nó React que você deseja renderizar em HTML. Por exemplo, um elemento JSX como `<Page />`.

* **optional** `options`: An object for server render.
* **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.
* **opcional** `options`: Um objeto para a renderização do servidor.
* **opcional** `identifierPrefix`: Um prefixo de string que o React usa para IDs gerados por [`useId`.](/reference/react/useId) Útil para evitar conflitos ao usar múltiplas raízes na mesma página.

#### Returns {/*returns*/}

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.
Um [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) que produz uma string HTML. O HTML resultante não pode ser hidratado no cliente.

#### Caveats {/*caveats*/}

* `renderToStaticNodeStream` output cannot be hydrated.
* A saída de `renderToStaticNodeStream` não pode ser hidratada.

* This method will wait for all [Suspense boundaries](/reference/react/Suspense) to complete before returning any output.
* Este método aguardará que todas as [Suspense boundaries](/reference/react/Suspense) sejam concluídas antes de retornar qualquer saída.

* As of React 18, this method buffers all of its output, so it doesn't actually provide any streaming benefits.
* A partir do React 18, este método armazena em buffer toda a sua saída, portanto, na verdade, não fornece nenhum benefício de streaming.

* The returned stream is a byte stream encoded in utf-8. If you need a stream in another encoding, take a look at a project like [iconv-lite](https://www.npmjs.com/package/iconv-lite), which provides transform streams for transcoding text.
* O stream retornado é um stream de bytes codificado em utf-8. Se você precisar de um stream em outra codificação, dê uma olhada em um projeto como [iconv-lite](https://www.npmjs.com/package/iconv-lite), que fornece streams de transformação para transcodificar texto.

---

## Usage {/*usage*/}

### Rendering a React tree as static HTML to a Node.js Readable Stream {/*rendering-a-react-tree-as-static-html-to-a-nodejs-readable-stream*/}

Call `renderToStaticNodeStream` to get a [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) which you can pipe to your server response:
Chame `renderToStaticNodeStream` para obter um [Node.js Readable Stream](https://nodejs.org/api/stream.html#readable-streams) que você pode enviar para a resposta do seu servidor:

```js {5-6}
import { renderToStaticNodeStream } from 'react-dom/server';

// The route handler syntax depends on your backend framework
// A sintaxe do manipulador de rota depende do seu framework de backend
app.use('/', (request, response) => {
const stream = renderToStaticNodeStream(<Page />);
stream.pipe(response);
});
```

The stream will produce the initial non-interactive HTML output of your React components.
O stream produzirá a saída HTML inicial não interativa de seus componentes React.

<Pitfall>

This method renders **non-interactive HTML that cannot be hydrated.** This is useful if you want to use React as a simple static page generator, or if you're rendering completely static content like emails.
Este método renderiza **HTML não interativo que não pode ser hidratado.** Isso é útil se você quiser usar o React como um simples gerador de páginas estáticas, ou se estiver renderizando conteúdo completamente estático como e-mails.

Interactive apps should use [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) on the server and [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) on the client.
Aplicativos interativos devem usar [`renderToPipeableStream`](/reference/react-dom/server/renderToPipeableStream) no servidor e [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) no cliente.

</Pitfall>
</Pitfall>
Loading