From 66aa693d7e44bee9333ba7fa03d6bb5c80d32b38 Mon Sep 17 00:00:00 2001 From: MaxDecapitars <60554060+MaxDecapitars@users.noreply.github.com> Date: Sat, 6 May 2023 22:38:27 -0500 Subject: [PATCH] Translate render to pipeable stream (#677) * translation of renderToPipeableStream.md * Improving the translation of some titles. * Naturalized translations --- .../server/renderToPipeableStream.md | 206 +++++++++--------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/src/content/reference/react-dom/server/renderToPipeableStream.md b/src/content/reference/react-dom/server/renderToPipeableStream.md index dee690372..45f454a15 100644 --- a/src/content/reference/react-dom/server/renderToPipeableStream.md +++ b/src/content/reference/react-dom/server/renderToPipeableStream.md @@ -4,7 +4,7 @@ title: renderToPipeableStream -`renderToPipeableStream` renders a React tree to a pipeable [Node.js Stream.](https://nodejs.org/api/stream.html) +`renderToPipeableStream` renderiza un árbol de React en un [*Stream* de Node.js](https://nodejs.org/api/stream.html) que se puede canalizar. ```js const { pipe, abort } = renderToPipeableStream(reactNode, options?) @@ -16,17 +16,17 @@ const { pipe, abort } = renderToPipeableStream(reactNode, options?) -This API is specific to Node.js. Environments with [Web Streams,](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) like Deno and modern edge runtimes, should use [`renderToReadableStream`](/reference/react-dom/server/renderToReadableStream) instead. +Esta API es específica para Node.js. Si estás trabajando en entornos con [Web *Streams*,](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) como Deno y *edge runtimes* modernos, utiliza [`renderToReadableStream`](/reference/react-dom/server/renderToReadableStream) en su lugar. --- -## Reference {/*reference*/} +## Referencia {/*reference*/} ### `renderToPipeableStream(reactNode, options?)` {/*rendertopipeablestream*/} -Call `renderToPipeableStream` to render your React tree as HTML into a [Node.js Stream.](https://nodejs.org/api/stream.html#writable-streams) +Llama a `renderToPipeableStream` para renderizar tu árbol de React como HTML en un [*Stream* de Node.js.](https://nodejs.org/api/stream.html#writable-streams) ```js import { renderToPipeableStream } from 'react-dom/server'; @@ -40,47 +40,47 @@ const { pipe } = renderToPipeableStream(, { }); ``` -On the client, call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to make the server-generated HTML interactive. +Para que el HTML generado por el servidor sea interactivo, llama a [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) en el cliente. -[See more examples below.](#usage) +[Ve más ejemplos.](#usage) -#### Parameters {/*parameters*/} +#### Parámetros {/*parameters*/} -* `reactNode`: A React node you want to render to HTML. For example, a JSX element like ``. It is expected to represent the entire document, so the `App` component should render the `` tag. +* `reactNode`: Un nodo de React que quieres renderizar como HTML. Por ejemplo, un elemento JSX como ``. Se espera que represente todo el documento, por lo que el componente `App` debería renderizar la etiqueta ``. -* **optional** `options`: An object with streaming options. - * **optional** `bootstrapScriptContent`: If specified, this string will be placed in an inline ` ``` -On the client, your bootstrap script should [hydrate the entire `document` with a call to `hydrateRoot`:](/reference/react-dom/client/hydrateRoot#hydrating-an-entire-document) +En el cliente, tu script de arranque debe [hidratar todo el `document` con una llamada a `hydrateRoot`:](/reference/react-dom/client/hydrateRoot#hydrating-an-entire-document) ```js [[1, 4, ""]] import { hydrateRoot } from 'react-dom/client'; @@ -133,15 +133,15 @@ import App from './App.js'; hydrateRoot(document, ); ``` -This will attach event listeners to the server-generated HTML and make it interactive. +Esto adjuntará escuchadores de eventos al HTML generado por el servidor y lo hará interactivo. -#### Reading CSS and JS asset paths from the build output {/*reading-css-and-js-asset-paths-from-the-build-output*/} +#### Lectura de rutas de recursos CSS y JS desde la salida de compilación {/*reading-css-and-js-asset-paths-from-the-build-output*/} -The final asset URLs (like JavaScript and CSS files) are often hashed after the build. For example, instead of `styles.css` you might end up with `styles.123456.css`. Hashing static asset filenames guarantees that every distinct build of the same asset will have a different filename. This is useful because it lets you safely enable long-term caching for static assets: a file with a certain name would never change content. +Las URLs finales de los recursos (como archivos JavaScript y CSS) a menudo se cifran después de la compilación. Por ejemplo, en lugar de `styles.css`, podrías terminar con `styles.123456.css`. El cifrado de los nombres de archivo de recursos estáticos garantiza que cada compilación distinta del mismo recurso tendrá un nombre de archivo diferente. Esto es útil porque te permite habilitar de manera segura el almacenamiento en caché a largo plazo para los recursos estáticos: un archivo con un nombre determinado nunca cambiará de contenido. -However, if you don't know the asset URLs until after the build, there's no way for you to put them in the source code. For example, hardcoding `"/styles.css"` into JSX like earlier wouldn't work. To keep them out of your source code, your root component can read the real filenames from a map passed as a prop: +Sin embargo, si no conoces las URLs de los recursos hasta después de la compilación, no hay forma de colocarlas en el código fuente. Por ejemplo, escribir `"/styles.css"` en JSX como se hizo antes no funcionaría. Para evitar incluirlos en el código fuente, tu componente raíz puede leer los nombres de archivo reales de un mapa pasado como una prop: ```js {1,6} export default function App({ assetMap }) { @@ -158,10 +158,10 @@ export default function App({ assetMap }) { } ``` -On the server, render `` and pass your `assetMap` with the asset URLs: +En el servidor, renderiza `` y pasa tu `assetMap` con las URLs de los recursos: ```js {1-5,8,9} -// You'd need to get this JSON from your build tooling, e.g. read it from the build output. +// Deberás obtener este JSON desde tus herramientas de compilación, por ejemplo, leyéndolo desde la salida de compilación. const assetMap = { 'styles.css': '/styles.123456.css', 'main.js': '/main.123456.js' @@ -178,10 +178,10 @@ app.use('/', (request, response) => { }); ``` -Since your server is now rendering ``, you need to render it with `assetMap` on the client too to avoid hydration errors. You can serialize and pass `assetMap` to the client like this: +Ahora que tu servidor está renderizando ``, debes renderizarlo también con `assetMap` en el cliente para evitar errores de hidratación. Puedes serializar y pasar `assetMap` al cliente de esta manera: ```js {9-10} -// You'd need to get this JSON from your build tooling. +// Deberás obtener este JSON desde tus herramientas de compilación. const assetMap = { 'styles.css': '/styles.123456.css', 'main.js': '/main.123456.js' @@ -189,7 +189,7 @@ const assetMap = { app.use('/', (request, response) => { const { pipe } = renderToPipeableStream(, { - // Careful: It's safe to stringify() this because this data isn't user-generated. + // Ten cuidado: es seguro stringify() ya que estos datos no son generados por el usuario. bootstrapScriptContent: `window.assetMap = ${JSON.stringify(assetMap)};`, bootstrapScripts: [assetMap['main.js']], onShellReady() { @@ -200,7 +200,7 @@ app.use('/', (request, response) => { }); ``` -In the example above, the `bootstrapScriptContent` option adds an extra inline `