Skip to content

Commit 4acb85e

Browse files
Adding translations to the renderToString function (#644)
* Adding translations to the renderToString function * Update renderToString.md --------- Co-authored-by: Rainer Martinez <[email protected]>
1 parent 5f7af5a commit 4acb85e

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

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

+37-38
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ title: renderToString
44

55
<Pitfall>
66

7-
`renderToString` does not support streaming or waiting for data. [See the alternatives.](#alternatives)
7+
`renderToString` no es compatible con transmisión (*streaming*) o espera de datos. [Ver alternativas.](#alternatives)
88

99
</Pitfall>
1010

1111
<Intro>
1212

13-
`renderToString` renders a React tree to an HTML string.
13+
`renderToString` renderiza un árbol de React como una cadena de HTML.
1414

1515
```js
1616
const html = renderToString(reactNode)
@@ -22,93 +22,93 @@ const html = renderToString(reactNode)
2222

2323
---
2424

25-
## Reference {/*reference*/}
25+
## Referencia {/*reference*/}
2626

2727
### `renderToString(reactNode)` {/*rendertostring*/}
2828

29-
On the server, call `renderToString` to render your app to HTML.
29+
En el servidor, llama a `renderToString` para renderizar tu aplicación a HTML.
3030

3131
```js
3232
import { renderToString } from 'react-dom/server';
3333

3434
const html = renderToString(<App />);
3535
```
3636

37-
On the client, call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to make the server-generated HTML interactive.
37+
En el cliente, llama a [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) para hacer que el HTML generado por el servidor sea interactivo.
3838

39-
[See more examples below.](#usage)
39+
[Ver más ejemplos a continuación.](#usage)
4040

41-
#### Parameters {/*parameters*/}
41+
#### Parámetros {/*parameters*/}
4242

43-
* `reactNode`: A React node you want to render to HTML. For example, a JSX node like `<App />`.
43+
* `reactNode`: Un nodo de React que deseas renderizar como HTML. Por ejemplo, un nodo JSX como `<App />`.
4444

4545
#### Returns {/*returns*/}
4646

47-
An HTML string.
47+
Una cadena de caracteres HTML.
4848

49-
#### Caveats {/*caveats*/}
49+
#### Advertencias {/*caveats*/}
5050

51-
* `renderToString` has limited Suspense support. If a component suspends, `renderToString` immediately sends its fallback as HTML.
51+
* `renderToString` tiene un soporte limitado para Suspense. Si un componente suspende, `renderToString` inmediatamente envía su fallback como HTML.
5252

53-
* `renderToString` works in the browser, but using it in the client code is [not recommended.](#removing-rendertostring-from-the-client-code)
53+
* `renderToString` funciona en el navegador, pero [no se recomienda](#removing-rendertostring-from-the-client-code) usarlo en el código del cliente.
5454

5555
---
5656

57-
## Usage {/*usage*/}
57+
## Uso {/*usage*/}
5858

59-
### Rendering a React tree as HTML to a string {/*rendering-a-react-tree-as-html-to-a-string*/}
59+
### Renderizar un árbol de React como HTML en una cadena de caracteres {/*rendering-a-react-tree-as-html-to-a-string*/}
6060

61-
Call `renderToString` to render your app to an HTML string which you can send with your server response:
61+
Llama a `renderToString` para renderizar tu aplicación como una cadena de caracteres HTML que puedes enviar con la respuesta del servidor:
6262

6363
```js {5-6}
6464
import { renderToString } from 'react-dom/server';
6565

66-
// The route handler syntax depends on your backend framework
66+
// La sintaxis del manejador de rutas depende de tu framework de backend.
6767
app.use('/', (request, response) => {
6868
const html = renderToString(<App />);
6969
response.send(html);
7070
});
7171
```
7272

73-
This will produce the initial non-interactive HTML output of your React components. On the client, you will need to call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to *hydrate* that server-generated HTML and make it interactive.
73+
Esto producirá la salida HTML inicial no interactiva de tus componentes de React. En el cliente, deberás llamar a [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) para *hidratar* ese HTML generado por el servidor y hacerlo interactivo.
7474

7575

7676
<Pitfall>
7777

78-
`renderToString` does not support streaming or waiting for data. [See the alternatives.](#alternatives)
78+
`renderToString` no es compatible con transmisión o espera de datos. [Ver alternativas.](#alternatives)
7979

8080
</Pitfall>
8181

8282
---
8383

84-
## Alternatives {/*alternatives*/}
84+
## Alternativas {/*alternatives*/}
8585

86-
### Migrating from `renderToString` to a streaming method on the server {/*migrating-from-rendertostring-to-a-streaming-method-on-the-server*/}
86+
### Migración de `renderToString` a un método de transmisión en el servidor {/*migrating-from-rendertostring-to-a-streaming-method-on-the-server*/}
8787

88-
`renderToString` returns a string immediately, so it does not support streaming or waiting for data.
88+
`renderToString` devuelve una cadena de caracteres de inmediato, por lo que no admite transmisión (*streaming*) o espera de datos.
8989

90-
When possible, we recommend to use these fully-featured alternatives:
90+
Cuando sea posible, recomendamos utilizar estas alternativas totalmente funcionales:
9191

92-
* If you use Node.js, use [`renderToPipeableStream`.](/reference/react-dom/server/renderToPipeableStream)
93-
* If you use Deno or a modern edge runtime with [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API), use [`renderToReadableStream`.](/reference/react-dom/server/renderToReadableStream)
92+
* Si utilizas Node.js, utiliza [`renderToPipeableStream`.](/reference/react-dom/server/renderToPipeableStream)
93+
* Si utilizas Deno o una versión moderna de runtime con [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API), utiliza [`renderToReadableStream`.](/reference/react-dom/server/renderToReadableStream)
9494

95-
You can continue using `renderToString` if your server environment does not support streams.
95+
Puedes continuar utilizando `renderToString` si tu entorno de servidor no admite *streams*.
9696

9797
---
9898

99-
### Removing `renderToString` from the client code {/*removing-rendertostring-from-the-client-code*/}
99+
### Eliminar `renderToString` del código del cliente {/*removing-rendertostring-from-the-client-code*/}
100100

101-
Sometimes, `renderToString` is used on the client to convert some component to HTML.
101+
A veces, se usa `renderToString` en el cliente para convertir algún componente en HTML.
102102

103103
```js {1-2}
104-
// 🚩 Unnecessary: using renderToString on the client
104+
// 🚩 Innecesario: usar renderToString en el cliente
105105
import { renderToString } from 'react-dom/server';
106106

107107
const html = renderToString(<MyIcon />);
108-
console.log(html); // For example, "<svg>...</svg>"
108+
console.log(html); // Por ejemplo, "<svg>...</svg>"
109109
```
110110

111-
Importing `react-dom/server` **on the client** unnecessarily increases your bundle size and should be avoided. If you need to render some component to HTML in the browser, use [`createRoot`](/reference/react-dom/client/createRoot) and read HTML from the DOM:
111+
Importar `react-dom/server` **en el cliente** aumenta innecesariamente el tamaño de tu paquete y debe evitarse. Si necesitas renderizar algún componente como HTML en el navegador, utiliza [`createRoot`](/reference/react-dom/client/createRoot) y lee el HTML desde el DOM:
112112

113113
```js
114114
import { createRoot } from 'react-dom/client';
@@ -119,20 +119,19 @@ const root = createRoot(div);
119119
flushSync(() => {
120120
root.render(<MyIcon />);
121121
});
122-
console.log(div.innerHTML); // For example, "<svg>...</svg>"
122+
console.log(div.innerHTML); // Por ejemplo, "<svg>...</svg>"
123123
```
124124

125-
The [`flushSync`](/reference/react-dom/flushSync) call is necessary so that the DOM is updated before reading its [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) property.
125+
La llamada a [`flushSync`](/reference/react-dom/flushSync) es necesaria para que el DOM se actualice antes de leer su propiedad [`innerHTML.`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)
126126

127127
---
128128

129-
## Troubleshooting {/*troubleshooting*/}
129+
## Solución de problemas {/*troubleshooting*/}
130130

131-
### When a component suspends, the HTML always contains a fallback {/*when-a-component-suspends-the-html-always-contains-a-fallback*/}
131+
### Cuando un componente se suspende, el HTML siempre contiene un fallback {/*when-a-component-suspends-the-html-always-contains-a-fallback*/}
132132

133-
`renderToString` does not fully support Suspense.
133+
`renderToString` no es compatible completamente con Suspense.
134134

135-
If some component suspends (for example, because it's defined with [`lazy`](/reference/react/lazy) or fetches data), `renderToString` will not wait for its content to resolve. Instead, `renderToString` will find the closest [`<Suspense>`](/reference/react/Suspense) boundary above it and render its `fallback` prop in the HTML. The content will not appear until the client code loads.
136-
137-
To solve this, use one of the [recommended streaming solutions.](#migrating-from-rendertostring-to-a-streaming-method-on-the-server) They can stream content in chunks as it resolves on the server so that the user sees the page being progressively filled in even before the client code loads.
135+
Si algún componente se suspende (Por ejemplo, porque está definido con [`lazy`](/reference/react/lazy) o busca datos), `renderToString` no esperará a que se resuelva su contenido. En su lugar, `renderToString` encontrará el límite de [`<Suspense>`](/reference/react/Suspense) más cercano por encima y renderizará su prop `fallback` en el HTML. El contenido no aparecerá hasta que se cargue el código del cliente.
138136

137+
Para resolver esto, utiliza una de las [soluciones de streaming recomendadas.](#migrating-from-rendertostring-to-a-streaming-method-on-the-server) Pueden transmitir contenido en trozos a medida que se resuelve en el servidor para que el usuario vea cómo se rellena la página progresivamente antes de que se cargue el código del cliente.

0 commit comments

Comments
 (0)