Skip to content

Commit 64df4a3

Browse files
khriztianmorenocarburo
authored andcommitted
Add the traslation for Portals (#131)
1 parent 8b7047a commit 64df4a3

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

content/docs/portals.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
---
22
id: portals
3-
title: Portals
3+
title: Portales
44
permalink: docs/portals.html
55
---
66

7-
Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
7+
Los portales proporcionan una opción de primera clase para renderizar hijos en un nodo DOM que existe por fuera de la jerarquía del DOM del Componente padre.
88

99
```js
1010
ReactDOM.createPortal(child, container)
1111
```
1212

13-
The first argument (`child`) is any [renderable React child](/docs/react-component.html#render), such as an element, string, or fragment. The second argument (`container`) is a DOM element.
13+
El primer argumento (`child`) es cualquier [hijo renderizable por React](/docs/react-component.html#render), como un elemento, cadena de caracteres o fragmento. El segundo argumento (`container`) es un elemento DOM.
1414

15-
## Usage {#usage}
15+
## Uso {#usage}
1616

17-
Normally, when you return an element from a component's render method, it's mounted into the DOM as a child of the nearest parent node:
17+
Normalmente, cuando retornas un elemento del método de render de un componente, este se monta en el DOM como un elemento hijo del nodo padre más cercano:
1818

1919
```js{4,6}
2020
render() {
21-
// React mounts a new div and renders the children into it
21+
// React crea un nuevo elemento y muestra al
22+
// componente hijo dentro de él.
2223
return (
2324
<div>
2425
{this.props.children}
@@ -27,34 +28,34 @@ render() {
2728
}
2829
```
2930

30-
However, sometimes it's useful to insert a child into a different location in the DOM:
31+
Sin embargo, a veces es útil insertar un hijo en una ubicación diferente en el DOM:
3132

3233
```js{6}
3334
render() {
34-
// React does *not* create a new div. It renders the children into `domNode`.
35-
// `domNode` is any valid DOM node, regardless of its location in the DOM.
35+
// React *no* crea un nuevo div, convierte el hijo en `domNode`.
36+
// `domNode` es cualquier nodo DOM válido, independientemente de su ubicación en el DOM.
3637
return ReactDOM.createPortal(
3738
this.props.children,
3839
domNode
3940
);
4041
}
4142
```
4243

43-
A typical use case for portals is when a parent component has an `overflow: hidden` or `z-index` style, but you need the child to visually "break out" of its container. For example, dialogs, hovercards, and tooltips.
44+
Un caso de uso típico de los portales es cuando un componente principal tiene un estilo `overflow: hidden` or `z-index`, pero necesita que el elemento "salga" visualmente de su contenedor. Por ejemplo, cuadros de diálogo, *hovercards* y *tooltips*.
4445

45-
> Note:
46+
> Nota:
4647
>
47-
> When working with portals, remember that [managing keyboard focus](/docs/accessibility.html#programmatically-managing-focus) becomes very important.
48+
> Cuando trabajes con portales, recuerda que [administrar el foco del teclado](/docs/accessibility.html#programmatically-managing-focus) es muy importante.
4849
>
49-
> For modal dialogs, ensure that everyone can interact with them by following the [WAI-ARIA Modal Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal).
50+
> Para los cuadros de diálogos, asegúrate de que todos puedan interactuar con ellos siguiendo las [Prácticas de creación modal de WAI-ARIA](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal).
5051
51-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/yzMaBd)
52+
[**Pruébalo en CodePen**](https://codepen.io/gaearon/pen/yzMaBd)
5253

53-
## Event Bubbling Through Portals {#event-bubbling-through-portals}
54+
## Propagación de eventos a través de Portales {#event-bubbling-through-portals}
5455

55-
Even though a portal can be anywhere in the DOM tree, it behaves like a normal React child in every other way. Features like context work exactly the same regardless of whether the child is a portal, as the portal still exists in the *React tree* regardless of position in the *DOM tree*.
56+
Aunque un portal puede estar en cualquier parte del árbol DOM, se comporta como un hijo de React normal en cualquier otra forma. Las características como el contexto funcionan exactamente de la misma manera, independientemente de si el elemento hijo es un portal, ya que el portal aún existe en el *árbol de React* sin importar la posición en el *árbol DOM*.
5657

57-
This includes event bubbling. An event fired from inside a portal will propagate to ancestors in the containing *React tree*, even if those elements are not ancestors in the *DOM tree*. Assuming the following HTML structure:
58+
Esto incluye propagación de eventos. Un evento activado desde adentro de un portal se propagará a los ancestros en el *árbol de React*, incluso si esos elementos no son ancestros en el *árbol DOM*. Asumiendo la siguiente estructura HTML:
5859

5960
```html
6061
<html>
@@ -65,10 +66,10 @@ This includes event bubbling. An event fired from inside a portal will propagate
6566
</html>
6667
```
6768

68-
A `Parent` component in `#app-root` would be able to catch an uncaught, bubbling event from the sibling node `#modal-root`.
69+
Un componente `Parent` en `#app-root` sería capaz de detectar un evento de propagación no capturado desde el nodo hermano `#modal-root`.
6970

7071
```js{28-31,42-49,53,61-63,70-71,74}
71-
// These two containers are siblings in the DOM
72+
// Estos dos contenedores son hermanos en el DOM.
7273
const appRoot = document.getElementById('app-root');
7374
const modalRoot = document.getElementById('modal-root');
7475
@@ -79,14 +80,13 @@ class Modal extends React.Component {
7980
}
8081
8182
componentDidMount() {
82-
// The portal element is inserted in the DOM tree after
83-
// the Modal's children are mounted, meaning that children
84-
// will be mounted on a detached DOM node. If a child
85-
// component requires to be attached to the DOM tree
86-
// immediately when mounted, for example to measure a
87-
// DOM node, or uses 'autoFocus' in a descendant, add
88-
// state to Modal and only render the children when Modal
89-
// is inserted in the DOM tree.
83+
// El elemento del portal se inserta en el árbol DOM después de
84+
// que se montan los hijos del Modal, lo que significa que los hijos
85+
// se montarán en un nodo DOM separado. Si un componente hijo
86+
// requiere estar conectado inmediatamente cuando se monta al árbol del DOM
87+
// por ejemplo, para medir un nodo DOM, o usar 'autoFocus' en un descendiente,
88+
// agrega el estado a Modal y renderiza solo a los hijos
89+
// cuando se inserta Modal en el árbol DOM.
9090
modalRoot.appendChild(this.el);
9191
}
9292
@@ -110,9 +110,9 @@ class Parent extends React.Component {
110110
}
111111
112112
handleClick() {
113-
// This will fire when the button in Child is clicked,
114-
// updating Parent's state, even though button
115-
// is not direct descendant in the DOM.
113+
// Esto se activará cuando el botón en el Child sea cliqueado,
114+
// actualizando el estado de Parent,
115+
// aunque el botón no sea descendiente directo en el DOM.
116116
this.setState(state => ({
117117
clicks: state.clicks + 1
118118
}));
@@ -137,8 +137,8 @@ class Parent extends React.Component {
137137
}
138138
139139
function Child() {
140-
// The click event on this button will bubble up to parent,
141-
// because there is no 'onClick' attribute defined
140+
// El evento de clic en este botón se convertirá en principal,
141+
// porque no hay un atributo 'onClick' definido.
142142
return (
143143
<div className="modal">
144144
<button>Click</button>
@@ -149,6 +149,6 @@ function Child() {
149149
ReactDOM.render(<Parent />, appRoot);
150150
```
151151

152-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/jGBWpE)
152+
[**Pruébalo en CodePen**](https://codepen.io/gaearon/pen/jGBWpE)
153153

154-
Catching an event bubbling up from a portal in a parent component allows the development of more flexible abstractions that are not inherently reliant on portals. For example, if you render a `<Modal />` component, the parent can capture its events regardless of whether it's implemented using portals.
154+
La captura de un evento que sale de un portal en un componente padre permite el desarrollo de abstracciones más flexibles que no dependen intrínsecamente de los portales. Por ejemplo, si renderizas un componente `<Modal />`, el padre puede capturar sus eventos sin importar si es implementado usando portales.

0 commit comments

Comments
 (0)