` DOM node is removed, React will call your `ref` callback with `null`.
+Cuando el nodo del DOM `
` es agregado a la pantalla, React llamará a tu callback `ref` con el nodo del DOM como argumento. Cuando ese nodo del DOM `
` se elimina, React llamará a tu callback `ref` con `null`.
-React will also call your `ref` callback whenever you pass a *different* `ref` callback. In the above example, `(node) => { ... }` is a different function on every render. When your component re-renders, the *previous* function will be called with `null` as the argument, and the *next* function will be called with the DOM node.
+React también llamará a tu callback `ref` cada vez que pases un callback `ref` *diferente*. En el ejemplo anterior, `(node) => { ... }` es una función diferente en cada renderizado. Cuando tu componente se vuelva a renderizar, la función *anterior* será llamada con `null` como argumento, y la *siguiente* función será llamada con el nodo del DOM.
-#### Parameters {/*ref-callback-parameters*/}
+#### Parámetros {/*ref-callback-parameters*/}
-* `node`: A DOM node or `null`. React will pass you the DOM node when the ref gets attached, and `null` when the ref gets detached. Unless you pass the same function reference for the `ref` callback on every render, the callback will get temporarily detached and re-attached during ever re-render of the component.
+* `node`: Un nodo del DOM o `null`. React te pasará el nodo del DOM cuando se vincule la ref, y `null` cuando la ref se desvincule. A menos que pases la misma función ref para el callback `ref` en cada renderizado, el callback se desprenderá temporalmente y se volverá a vincular durante cada renderizado del componente.
-#### Returns {/*returns*/}
+#### Retornos {/*returns*/}
-Do not return anything from the `ref` callback.
+No retornes nada desde el callback `ref`.
---
-### React event object {/*react-event-object*/}
+### Objeto de evento de React {/*react-event-object*/}
-Your event handlers will receive a *React event object.* It is also sometimes known as a "synthetic event".
+Los manejadores de eventos recibirán un *objeto de evento de React.* A veces también se le conoce como un "evento sintético".
```js
{
- console.log(e); // React event object
+ console.log(e); // Objeto de evento de React
}} />
```
-It conforms to the same standard as the underlying DOM events, but fixes some browser inconsistencies.
+Cumple con el mismo estándar que los eventos DOM subyacentes, pero soluciona algunas inconsistencia del navegador.
-Some React events do not map directly to the browser's native events. For example in `onMouseLeave`, `e.nativeEvent` will point to a `mouseout` event. The specific mapping is not part of the public API and may change in the future. If you need the underlying browser event for some reason, read it from `e.nativeEvent`.
+Algunos eventos de React no se asignan directamente a los eventos nativos del navegador. Por ejemplo en `onMouseLeave`, `e.nativeEvent` apuntará a un evento `mouseout`. La asignación específica no forma parte de la API pública y puede cambiar en el futuro. Si necesitas el evento del navegador subyacente por alguna razón, léelo desde `e.nativeEvent`.
-#### Properties {/*react-event-object-properties*/}
+#### Propiedades {/*react-event-object-properties*/}
-React event objects implement some of the standard [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) properties:
+Los objetos de evento de React implementan algunas de las propiedades estándar de [`Evento`](https://developer.mozilla.org/es/docs/Web/API/Event):
-* [`bubbles`](https://developer.mozilla.org/en-US/docs/Web/API/Event/bubbles): A boolean. Returns whether the event bubbles through the DOM.
-* [`cancelable`](https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable): A boolean. Returns whether the event can be canceled.
-* [`currentTarget`](https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget): A DOM node. Returns the node to which the current handler is attached in the React tree.
-* [`defaultPrevented`](https://developer.mozilla.org/en-US/docs/Web/API/Event/defaultPrevented): A boolean. Returns whether `preventDefault` was called.
-* [`eventPhase`](https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase): A number. Returns which phase the event is currently in.
-* [`isTrusted`](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted): A boolean. Returns whether the event was initiated by user.
-* [`target`](https://developer.mozilla.org/en-US/docs/Web/API/Event/target): A DOM node. Returns the node on which the event has occurred (which could be a distant child).
-* [`timeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp): A number. Returns the time when the event occurred.
+* [`bubbles`](https://developer.mozilla.org/es/docs/Web/API/Event/bubbles): Un booleano. Devuelve si el evento se propaga a través del DOM.
+* [`cancelable`](https://developer.mozilla.org/es/docs/Web/API/Event/cancelable): Un booleano. Devuelve si el evento se puede cancelar.
+* [`currentTarget`](https://developer.mozilla.org/es/docs/Web/API/Event/currentTarget): Un nodo del DOM. Devuelve el nodo al que se vincula el manejador de eventos actual en el árbol de React.
+* [`defaultPrevented`](https://developer.mozilla.org/es/docs/Web/API/Event/defaultPrevented): Un booleano. Devuelve si se llamó a `preventDefault`.
+* [`eventPhase`](https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase): Un número. Devuelve en qué fase se encuentra el evento actualmente.
+* [`isTrusted`](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted): Un booleano. Devuelve si el evento fue iniciado por el usuario.
+* [`target`](https://developer.mozilla.org/es/docs/Web/API/Event/target): Un nodo del DOM. Devuelve el nodo en el que ha ocurrido el evento (que podría ser un hijo distante)
+* [`timeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp): Un número. Devuelve la hora (en milisegundos) en la que ocurrió el evento.
-Additionally, React event objects provide these properties:
+Además, los objetos de evento de React proporcionan estas propiedades:
-* `nativeEvent`: A DOM [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). The original browser event object.
+* `nativeEvent`: Un [`Evento`](https://developer.mozilla.org/es/docs/Web/API/Event) del DOM. El objeto de evento original del navegador.
-#### Methods {/*react-event-object-methods*/}
+#### Métodos {/*react-event-object-methods*/}
-React event objects implement some of the standard [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) methods:
+Los objetos de evento de React implementan algunos de los métodos estándar de [`Evento`](https://developer.mozilla.org/es/docs/Web/API/Event):
-* [`preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault): Prevents the default browser action for the event.
-* [`stopPropagation()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation): Stops the event propagation through the React tree.
+* [`preventDefault()`](https://developer.mozilla.org/es/docs/Web/API/Event/preventDefault): Evita la acción del navegador predeterminada para el evento.
+* [`stopPropagation()`](https://developer.mozilla.org/es/docs/Web/API/Event/stopPropagation): Detiene la propagación del evento a través del árbol de React.
-Additionally, React event objects provide these methods:
+Además, los objetos de evento de React proporcionan estos métodos:
-* `isDefaultPrevented()`: Returns a boolean value indicating whether `preventDefault` was called.
-* `isPropagationStopped()`: Returns a boolean value indicating whether `stopPropagation` was called.
-* `persist()`: Not used with React DOM. With React Native, call this to read event's properties after the event.
-* `isPersistent()`: Not used with React DOM. With React Native, returns whether `persist` has been called.
+* `isDefaultPrevented()`: Devuelve un valor booleano que indica si se llamó a `preventDefault`.
+* `isPropagationStopped()`: Devuelve un valor booleano que indica si se llamó a `stopPropagation`.
+* `persist()`: No se usa con React DOM. Con React Native, llámalo para leer las propiedades del evento después del evento.
+* `isPersistent()`: No se usa con React DOM. Con React Native, devuelve si se ha llamado a persist.
-#### Caveats {/*react-event-object-caveats*/}
+#### Advertencias {/*react-event-object-caveats*/}
-* The values of `currentTarget`, `eventPhase`, `target`, and `type` reflect the values your React code expects. Under the hood, React attaches event handlers at the root, but this is not reflected in React event objects. For example, `e.currentTarget` may not be the same as the underlying `e.nativeEvent.currentTarget`. For polyfilled events, `e.type` (React event type) may differ from `e.nativeEvent.type` (underlying type).
+* Los valores de `currentTarget`, `eventPhase`, `target`, y `type` reflejan los valores que tu código de React espera. Sin embargo, internamente, React vincula los manejadores de eventos en la raíz, pero esto no se refleja en los objetos de evento de React. Por ejemplo, `e.currentTarget` puede no ser lo mismo que el valor subyacente `e.nativeEvent.currentTarget`. Para eventos con polyfills, `e.type` (tipo de evento de React) puede ser diferente de `e.nativeEvent.type` (tipo subyacente).
---
-### `AnimationEvent` handler function {/*animationevent-handler*/}
+### Función manejadora de eventos `AnimationEvent` {/*animationevent-handler*/}
-An event handler type for the [CSS animation](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations) events.
+Un tipo de manejador de eventos para los eventos de [animación CSS](https://developer.mozilla.org/es/docs/Web/CSS/CSS_Animations/Using_CSS_animations).
```js
```
-#### Parameters {/*animationevent-handler-parameters*/}
+#### Parámetros {/*animationevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`AnimationEvent`](https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent) properties:
- * [`animationName`](https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent/animationName)
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`AnimationEvent`](https://developer.mozilla.org/es/docs/Web/API/AnimationEvent):
+ * [`animationName`](https://developer.mozilla.org/es/docs/Web/API/AnimationEvent/animationName)
* [`elapsedTime`](https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent/elapsedTime)
- * [`pseudoElement`](https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent)
+ * [`pseudoElement`](https://developer.mozilla.org/es/docs/Web/API/AnimationEvent)
---
-### `ClipboardEvent` handler function {/*clipboadevent-handler*/}
+### Función manejadora de eventos `ClipboardEvent` {/*clipboadevent-handler*/}
-An event handler type for the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) events.
+Un tipo de manejador de eventos para los eventos de [Clipboard API](https://developer.mozilla.org/es/docs/Web/API/Clipboard_API).
```js
```
-#### Parameters {/*clipboadevent-handler-parameters*/}
+#### Parámetros {/*clipboadevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`ClipboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`ClipboardEvent`](https://developer.mozilla.org/es/docs/Web/API/ClipboardEvent):
- * [`clipboardData`](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/clipboardData)
+ * [`clipboardData`](https://developer.mozilla.org/es/docs/Web/API/ClipboardEvent/clipboardData)
---
-### `CompositionEvent` handler function {/*compositionevent-handler*/}
+### Función manejadora de eventos `CompositionEvent` {/*compositionevent-handler*/}
-An event handler type for the [input method editor (IME)](https://developer.mozilla.org/en-US/docs/Glossary/Input_method_editor) events.
+Un tipo de manejador de eventos para los eventos del [editor de métodos de entrada](https://developer.mozilla.org/en-US/docs/Glossary/Input_method_editor).
```js
```
-#### Parameters {/*compositionevent-handler-parameters*/}
+#### Parámetros {/*compositionevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`CompositionEvent`](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`CompositionEvent`](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent):
* [`data`](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent/data)
---
-### `DragEvent` handler function {/*dragevent-handler*/}
+### Función manejadora de eventos `DragEvent` {/*dragevent-handler*/}
-An event handler type for the [HTML Drag and Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API) events.
+Un tipo de manejador de eventos para los eventos de la [API de arrastrar y soltar de HTML](https://developer.mozilla.org/es/docs/Web/API/HTML_Drag_and_Drop_API).
```js
<>
@@ -390,7 +390,7 @@ An event handler type for the [HTML Drag and Drop API](https://developer.mozilla
onDragStart={e => console.log('onDragStart')}
onDragEnd={e => console.log('onDragEnd')}
>
- Drag source
+ Fuente de arrastre
{ e.preventDefault(); console.log('onDragOver'); }}
onDrop={e => console.log('onDrop')}
>
- Drop target
+ Área de destino
>
```
-#### Parameters {/*dragevent-handler-parameters*/}
+#### Parámetros {/*dragevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`DragEvent`](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`DragEvent`](https://developer.mozilla.org/es/docs/Web/API/DragEvent):
* [`dataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/dataTransfer)
- It also includes the inherited [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) properties:
+ También incluye las propiedades heredadas de [`MouseEvent`](https://developer.mozilla.org/es/docs/Web/API/MouseEvent):
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
* [`button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
@@ -428,16 +428,16 @@ An event handler type for the [HTML Drag and Drop API](https://developer.mozilla
* [`screenY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ También incluye las propiedades heredadas de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `FocusEvent` handler function {/*focusevent-handler*/}
+### Función manejadora de eventos `FocusEvent` {/*focusevent-handler*/}
-An event handler type for the focus events.
+Un tipo de manejador de eventos para los eventos de foco.
```js
```
-[See an example.](#handling-focus-events)
+[Mira un ejemplo.](#handling-focus-events)
-#### Parameters {/*focusevent-handler-parameters*/}
+#### Parámetros {/*focusevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`FocusEvent`](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`FocusEvent`](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent):
* [`relatedTarget`](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/relatedTarget)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ También incluye las propiedades heredadas de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `Event` handler function {/*event-handler*/}
+### Función manejadora de eventos `Event` {/*event-handler*/}
-An event handler type for generic events.
+Un tipo de función manejadora de eventos genéricos.
-#### Parameters {/*event-handler-parameters*/}
+#### Parámetros {/*event-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with no additional properties.
+* `e`: Un [objeto de evento de React](#react-event-object) sin propiedades adicionales.
---
-### `InputEvent` handler function {/*inputevent-handler*/}
+### Función manejadora de eventos `InputEvent` {/*inputevent-handler*/}
-An event handler type for the `onBeforeInput` event.
+Un tipo de manejador de eventos para el evento `onBeforeInput`.
```js
console.log('onBeforeInput')} />
```
-#### Parameters {/*inputevent-handler-parameters*/}
+#### Parámetros {/*inputevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent):
* [`data`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/data)
---
-### `KeyboardEvent` handler function {/*keyboardevent-handler*/}
+### Función manejadora de eventos `KeyboardEvent` {/*keyboardevent-handler*/}
-An event handler type for keyboard events.
+Un tipo de manejador de eventos para eventos de teclado.
```js
```
-[See an example.](#handling-keyboard-events)
+[Mira un ejemplo.](#handling-keyboard-events)
-#### Parameters {/*keyboardevent-handler-parameters*/}
+#### Parámetros {/*keyboardevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`KeyboardEvent`](https://developer.mozilla.org/es/docs/Web/API/KeyboardEvent):
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/altKey)
* [`charCode`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode)
* [`code`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
@@ -509,22 +509,22 @@ An event handler type for keyboard events.
* [`key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
* [`keyCode`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode)
* [`locale`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/locale)
- * [`metaKey`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/metaKey)
+ * [`metaKey`](https://developer.mozilla.org/es/docs/Web/API/KeyboardEvent/metaKey)
* [`location`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/location)
* [`repeat`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat)
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/shiftKey)
- * [`which`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which)
+ * [`which`](https://developer.mozilla.org/es/docs/Web/API/UIEvent/which)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ También incluye las propiedades heredadas de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `MouseEvent` handler function {/*mouseevent-handler*/}
+### Función manejadora de eventos `MouseEvent` {/*mouseevent-handler*/}
-An event handler type for mouse events.
+Un tipo de manejador de eventos para eventos del mouse.
```js
```
-[See an example.](#handling-mouse-events)
+[Mira un ejemplo.](#handling-mouse-events)
-#### Parameters {/*mouseevent-handler-parameters*/}
+#### Parámetros {/*mouseevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`MouseEvent`](https://developer.mozilla.org/es/docs/Web/API/MouseEvent):
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
* [`button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
* [`buttons`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons)
@@ -557,18 +557,18 @@ An event handler type for mouse events.
* [`relatedTarget`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/relatedTarget)
* [`screenX`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenX)
* [`screenY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
- * [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
+ * [`shiftKey`](https://developer.mozilla.org/es/docs/Web/API/MouseEvent/shiftKey)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ También incluye las propiedades heredadas de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `PointerEvent` handler function {/*pointerevent-handler*/}
+### Función manejadora de eventos `PointerEvent` {/*pointerevent-handler*/}
-An event handler type for [pointer events.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
+Un tipo de manejador de eventos para [eventos del puntero.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
```js
```
-[See an example.](#handling-pointer-events)
+[Mira un ejemplo.](#handling-pointer-events)
-#### Parameters {/*pointerevent-handler-parameters*/}
+#### Parámetros {/*pointerevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent):
* [`height`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height)
* [`isPrimary`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary)
* [`pointerId`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId)
@@ -596,7 +596,7 @@ An event handler type for [pointer events.](https://developer.mozilla.org/en-US/
* [`twist`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/twist)
* [`width`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width)
- It also includes the inherited [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) properties:
+ También incluye las propiedades heredadas de [`MouseEvent`](https://developer.mozilla.org/es/docs/Web/API/MouseEvent):
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
* [`button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
@@ -615,16 +615,16 @@ An event handler type for [pointer events.](https://developer.mozilla.org/en-US/
* [`screenY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ También incluye las propiedades heredadas de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `TouchEvent` handler function {/*touchevent-handler*/}
+### Función manejadora de eventos `TouchEvent` {/*touchevent-handler*/}
-An event handler type for [touch events.](https://developer.mozilla.org/en-US/docs/Web/API/Touch_events)
+Un tipo de manejador de eventos para [eventos táctiles.](https://developer.mozilla.org/es/docs/Web/API/Touch_events)
```js
```
-#### Parameters {/*touchevent-handler-parameters*/}
+#### Parámetros {/*touchevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`TouchEvent`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`TouchEvent`](https://developer.mozilla.org/es/docs/Web/API/TouchEvent):
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/altKey)
* [`ctrlKey`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/ctrlKey)
* [`changedTouches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/changedTouches)
@@ -647,16 +647,16 @@ An event handler type for [touch events.](https://developer.mozilla.org/en-US/do
* [`touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches)
* [`targetTouches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/targetTouches)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ También incluye las propiedades heredadas de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-### `TransitionEvent` handler function {/*transitionevent-handler*/}
+### Función manejadora de eventos `TransitionEvent` {/*transitionevent-handler*/}
-An event handler type for the CSS transition events.
+Un tipo de manejador de eventos para los eventos de transición CSS.
```js
```
-#### Parameters {/*transitionevent-handler-parameters*/}
+#### Parámetros {/*transitionevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`TransitionEvent`](https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`TransitionEvent`](https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent):
* [`elapsedTime`](https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent/elapsedTime)
* [`propertyName`](https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent/propertyName)
* [`pseudoElement`](https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent/pseudoElement)
---
-### `UIEvent` handler function {/*uievent-handler*/}
+### Función manejadora de eventos `UIEvent` {/*uievent-handler*/}
-An event handler type for generic UI events.
+Un tipo de manejador de eventos para eventos de UI genéricos.
```js
```
-#### Parameters {/*uievent-handler-parameters*/}
+#### Parámetros {/*uievent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
-
+
---
-### `WheelEvent` handler function {/*wheelevent-handler*/}
+### Función manejadora de eventos `WheelEvent` {/*wheelevent-handler*/}
-An event handler type for the `onWheel` event.
+Un tipo de manejador de eventos para el evento `onWheel`.
```js
```
-#### Parameters {/*wheelevent-handler-parameters*/}
+#### Parámetros {/*wheelevent-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with these extra [`WheelEvent`](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent) properties:
+* `e`: Un [objeto de evento de React](#react-event-object) con propiedades adicionales de [`WheelEvent`](https://developer.mozilla.org/es/docs/Web/API/WheelEvent):
* [`deltaMode`](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode)
* [`deltaX`](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaX)
* [`deltaY`](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaY)
* [`deltaZ`](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaZ)
- It also includes the inherited [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) properties:
+ También incluye las propiedades heredadas de [`MouseEvent`](https://developer.mozilla.org/es/docs/Web/API/MouseEvent):
* [`altKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
* [`button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
@@ -729,35 +729,35 @@ An event handler type for the `onWheel` event.
* [`screenY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ También incluye las propiedades heredadas de [`UIEvent`](https://developer.mozilla.org/es/docs/Web/API/UIEvent):
* [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail)
* [`view`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view)
---
-## Usage {/*usage*/}
+## Uso {/*usage*/}
-### Applying CSS styles {/*applying-css-styles*/}
+### Aplicar estilos CSS {/*applying-css-styles*/}
-In React, you specify a CSS class with [`className`.](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) It works like the `class` attribute in HTML:
+En React, se especifica una clase de CSS con [`className`.](https://developer.mozilla.org/es/docs/Web/API/Element/className) Funciona como el atributo `class`en HTML:
```js
```
-Then you write the CSS rules for it in a separate CSS file:
+Luego, se escriben las reglas CSS para dicha clase en un archivo CSS separado.
```css
-/* In your CSS */
+/* En tu archivo CSS */
.avatar {
border-radius: 50%;
}
```
-React does not prescribe how you add CSS files. In the simplest case, you'll add a [`
`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) tag to your HTML. If you use a build tool or a framework, consult its documentation to learn how to add a CSS file to your project.
+React no indica cómo agregar archivos CSS. En el caso más simple, añadirás una etiqueta [`
`](https://developer.mozilla.org/es/docs/Web/HTML/Element/link) en el HTML. Si usas un framework o alguna herramienta de compilación, consulta su documentación para aprender cómo añadir un archivo CSS a tu proyecto.
-Sometimes, the style values depend on data. Use the `style` attribute to pass some styles dynamically:
+A veces, los valores de estilo dependen de los datos. Usa el atributo `style` para pasar algunos estilos dinámicamente:
```js {3-6}
@@ -814,13 +814,13 @@ export default function Avatar({ user }) {
-#### How to apply multiple CSS classes conditionally? {/*how-to-apply-multiple-css-classes-conditionally*/}
+#### ¿Cómo aplicar múltiples clases de CSS de forma condicional? {/*how-to-apply-multiple-css-classes-conditionally*/}
-To apply CSS classes conditionally, you need to produce the `className` string yourself using JavaScript.
+Para aplicar clases de CSS de forma condicional, necesitas producir el string de `className` tú mismo utilizando JavaScript.
-For example, `className={'row ' + (isSelected ? 'selected': '')}` will produce either `className="row"` or `className="row selected"` depending on whether `isSelected` is `true`.
+Por ejemplo, `className={'row ' + (isSelected ? 'selected': '')}` producirá ya sea `className="row"` o `className="row selected"` dependiendo de si `isSelected` es `true`.
-To make this more readable, you can use a tiny helper library like [`classnames`:](https://github.com/JedWatson/classnames)
+Para hacer esto más legible, puedes usar una pequeña biblioteca de ayuda como [`classnames`:](https://github.com/JedWatson/classnames)
```js
import cn from 'classnames';
@@ -834,7 +834,7 @@ function Row({ isSelected }) {
}
```
-It is especially convenient if you have multiple conditional classes:
+Es conveniente si tienes múltiples clases condicionales:
```js
import cn from 'classnames';
@@ -856,11 +856,11 @@ function Row({ isSelected, size }) {
---
-### Manipulating a DOM node with a ref {/*manipulating-a-dom-node-with-a-ref*/}
+### Manipular un nodo del DOM con una ref {/*manipulating-a-dom-node-with-a-ref*/}
-Sometimes, you'll need to get the browser DOM node associated with a tag in JSX. For example, if you want to focus an ` ` when a button is clicked, you need to call [`focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the browser ` ` DOM node.
+A veces, necesitarás obtener el nodo del DOM del navegador asociado con una etiqueta en JSX. Por ejemplo, si quieres enfocar un ` ` cuando se hace clic en un botón, necesitas llamar a [`focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) en el nodo del DOM ` ` del navegador.
-To obtain the browser DOM node for a tag, [declare a ref](/reference/react/useRef) and pass it as the `ref` attribute to that tag:
+Para obtener el nodo del DOM del navegador de una etiqueta, declara una ref y pásala como el atributo ref a esa etiqueta:
```js {7}
import { useRef } from 'react';
@@ -873,7 +873,7 @@ export default function Form() {
// ...
```
-React will put the DOM node into `inputRef.current` after it's been rendered to the screen.
+React pondrá el nodo del DOM en `inputRef.current` después de que haya sido renderizado en la pantalla.
@@ -900,24 +900,24 @@ export default function Form() {
-Read more about [manipulating DOM with refs](/learn/manipulating-the-dom-with-refs) and [check out more examples.](/reference/react/useRef#examples-dom)
+Lee más sobre [manipular el DOM con refs](/learn/manipulating-the-dom-with-refs) y [revisa más ejemplos.](/reference/react/useRef#examples-dom)
-For more advanced use cases, the `ref` attribute also accepts a [callback function.](#ref-callback)
+Para casos de uso más avanzados, el atributo ref también acepta una [función callback.](#ref-callback)
---
-### Dangerously setting the inner HTML {/*dangerously-setting-the-inner-html*/}
+### dangerouslySetInnerHTML {/*dangerously-setting-the-inner-html*/}
-You can pass a raw HTML string to an element like so:
+Puedes pasar un string HTML sin procesar a un elemento de esta manera:
```js
const markup = { __html: 'some raw html
' };
return
;
```
-**This is dangerous. As with the underlying DOM [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) property, you must exercise extreme caution! Unless the markup is coming from a completely trusted source, it is trivial to introduce an [XSS](https://en.wikipedia.org/wiki/Cross-site_scripting) vulnerability this way.**
+**Esto es peligroso. Al igual que con la propiedad subyacente del DOM [`innerHTML`](https://developer.mozilla.org/es/docs/Web/API/Element/innerHTML), debes tener precaución extrema! A menos que el markup venga de una fuente completamente confiable, se podría correr el riesgo de introducir una vulnerabilidad [XSS](https://es.wikipedia.org/wiki/Cross-site_scripting) de esta manera.**
-For example, if you use a Markdown library that converts Markdown to HTML, you trust that its parser doesn't contain bugs, and the user only sees their own input, you can display the resulting HTML like this:
+Por ejemplo, si utilizas una biblioteca de Markdown que convierte Markdown a HTML, debes confiar en que el parser no contenga errores y el usuario sólo vea su propio input, puedes mostrar el HTML resultante de esta manera:
@@ -930,7 +930,7 @@ export default function MarkdownEditor() {
return (
<>
- Enter some markdown:
+ Ingresa texto en markdown:
-To see why rendering arbitrary HTML is dangerous, replace the code above with this:
+Para entender por qué el renderizado arbitrario de HTML es peligroso, reemplaza el código anterior con esto:
```js {1-4,7,8}
const post = {
- // Imagine this content is stored in the database.
- content: ` `
+ // // Imagina que este contenido se almacena en la base de datos.
+ content: ` `
};
export default function MarkdownPreview() {
- // 🔴 SECURITY HOLE: passing untrusted input to dangerouslySetInnerHTML
+ // 🔴 AGUJERO DE SEGURIDAD: pasando input no confiable a dangerouslySetInnerHTML.
const markup = { __html: post.content };
return
;
}
```
-The code embedded in the HTML will run. A hacker could use this security hole to steal user information or to perform actions on their behalf. **Only use `dangerouslySetInnerHTML` with trusted and sanitized data.**
+El código incrustado en el HTML se ejecutará. Un hacker podría utilizar este agujero de seguridad para robar información de los usuarios o realizar acciones en su nombre. **Solo usa `dangerouslySetInnerHTML` con datos confiables y sanitizados.**
---
-### Handling mouse events {/*handling-mouse-events*/}
+### Manejo de eventos del mouse {/*handling-mouse-events*/}
-This example shows some common [mouse events](#mouseevent-handler) and when they fire.
+Este ejemplo muestra algunos [eventos del mouse](#mouseevent-handler) comunes y cuándo se disparan.
@@ -1051,9 +1051,9 @@ input { margin-left: 10px; }
---
-### Handling pointer events {/*handling-pointer-events*/}
+### Manejo de eventos del puntero {/*handling-pointer-events*/}
-This example shows some common [pointer events](#pointerevent-handler) and when they fire.
+Este ejemplo muestra algunos [eventos del puntero](#pointerevent-handler) comunes y cuándo se disparan.
@@ -1099,9 +1099,9 @@ input { margin-left: 10px; }
---
-### Handling focus events {/*handling-focus-events*/}
+### Manejo de eventos de foco {/*handling-focus-events*/}
-In React, [focus events](#focusevent-handler) bubble. You can use the `currentTarget` and `relatedTarget` to differentiate if the focusing or blurring events originated from outside of the parent element. The example shows how to detect focusing a child, focusing the parent element, and how to detect focus entering or leaving the whole subtree.
+En React, los [eventos de foco](#focusevent-handler) se propagan. Puedes usar el `currentTarget` y `relatedTarget` para diferenciar si los eventos de enfoque o desenfoque se originaron fuera del elemento padre. El ejemplo muestra cómo detectar el enfoque en un hijo, el enfoque en el elemento padre, y cómo detectar el enfoque al entrar o salir de todo el subárbol.
@@ -1117,7 +1117,7 @@ export default function FocusExample() {
console.log('focused child', e.target.name);
}
if (!e.currentTarget.contains(e.relatedTarget)) {
- // Not triggered when swapping focus between children
+ // No se activa al cambiar el enfoque entre los hijos
console.log('focus entered parent');
}
}}
@@ -1128,7 +1128,7 @@ export default function FocusExample() {
console.log('unfocused child', e.target.name);
}
if (!e.currentTarget.contains(e.relatedTarget)) {
- // Not triggered when swapping focus between children
+ // No se activa al cambiar el enfoque entre los hijos
console.log('focus left parent');
}
}}
@@ -1155,9 +1155,9 @@ input { margin-left: 10px; }
---
-### Handling keyboard events {/*handling-keyboard-events*/}
+### Manejo de eventos de teclado {/*handling-keyboard-events*/}
-This example shows some common [keyboard events](#keyboardevent-handler) and when they fire.
+Este ejemplo muestra algunos [eventos del teclado](#keyboardevent-handler) comunes y cuándo se disparan.