` DOM node is removed, React will call your `ref` callback with `null`.
+Quando o nó DOM `
` é adicionado à tela, o React chamará sua callback `ref` com o `node` DOM como argumento. Quando aquele nó DOM `
` é removido, o React chamará sua callback `ref` com `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.
+O React também chamará sua callback `ref` sempre que você passar uma *callback* `ref` *diferente*. No exemplo acima, `(node) => { ... }` é uma função diferente em cada renderização. Quando seu componente re-renderiza, a *anterior* função será chamada com `null` como argumento, e a *próxima* função será chamada com o nó 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 every re-render of the component.
+* `node`: Um nó DOM ou `null`. O React lhe passará o nó DOM quando a ref for anexada, e `null` quando a ref for destacada. A menos que você passe a mesma referência de função para a callback `ref` em cada renderização, a callback será temporariamente destacada e reanexada durante cada re-renderização do componente.
-#### Returns {/*returns*/}
+#### Retorna {/*returns*/}
-* **optional** `cleanup function`: When the `ref` is detached, React will call the cleanup function. If a function is not returned by the `ref` callback, React will call the callback again with `null` as the argument when the `ref` gets detached.
+* **opcional** `função de limpeza`: Quando a `ref` é destacada, o React chamará a função de limpeza. Se uma função não for retornada pela callback `ref`, o React chamará a callback novamente com `null` como argumento quando a `ref` for destacada.
```js
@@ -271,75 +271,75 @@ React will also call your `ref` callback whenever you pass a *different* `ref` c
console.log(node);
return () => {
- console.log('Clean up', node)
+ console.log('Limpeza', node)
}
}}>
```
-#### Caveats {/*caveats*/}
+#### Ressalvas {/*caveats*/}
-* When Strict Mode is on, React will **run one extra development-only setup+cleanup cycle** before the first real setup. This is a stress-test that ensures that your cleanup logic "mirrors" your setup logic and that it stops or undoes whatever the setup is doing. If this causes a problem, implement the cleanup function.
-* When you pass a *different* `ref` callback, React will call the *previous* callback's cleanup function if provided. If not cleanup function is defined, the `ref` callback will be called with `null` as the argument. The *next* function will be called with the DOM node.
+* Quando o Modo Estrito está ativado, o React **executará um ciclo extra de configuração+limpeza somente para desenvolvimento** antes da primeira configuração real. Este é um teste de estresse que garante que sua lógica de limpeza "reflete" sua lógica de configuração e que ela para ou reverte o que a configuração está fazendo. Se isso causar um problema, implemente a função de limpeza.
+* Quando você passar uma *callback* `ref` *diferente*, o React chamará a função de limpeza da *callback* anterior, se fornecida. Se nenhuma função de limpeza for definida, a callback `ref` será chamada com `null` como argumento. A *próxima* função será chamada com o nó DOM.
---
-### React event object {/*react-event-object*/}
+### Objeto de evento do React {/*react-event-object*/}
-Your event handlers will receive a *React event object.* It is also sometimes known as a "synthetic event".
+Seus manipuladores de eventos receberão um *objeto de evento do React*. Às vezes, ele também é conhecido como um "evento sintético".
```js
{
- console.log(e); // React event object
+ console.log(e); // Objeto de evento do React
}} />
```
-It conforms to the same standard as the underlying DOM events, but fixes some browser inconsistencies.
+Ele se conforma ao mesmo padrão que os eventos DOM subjacentes, mas corrige algumas inconsistências dos navegadores.
-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`.
+Alguns eventos do React não se mapeiam diretamente para os eventos nativos do navegador. Por exemplo, em `onMouseLeave`, `e.nativeEvent` apontará para um evento `mouseout`. O mapeamento específico não faz parte da API pública e pode mudar no futuro. Se você precisar do evento do navegador subjacente por algum motivo, leia a partir de `e.nativeEvent`.
-#### Properties {/*react-event-object-properties*/}
+#### Propriedades {/*react-event-object-properties*/}
-React event objects implement some of the standard [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) properties:
+Os objetos de evento do React implementam algumas das propriedades padrão do [`Event`](https://developer.mozilla.org/en-US/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/en-US/docs/Web/API/Event/bubbles): Um booleano. Retorna se o evento borbulha através do DOM.
+* [`cancelable`](https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable): Um booleano. Retorna se o evento pode ser cancelado.
+* [`currentTarget`](https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget): Um nó DOM. Retorna o nó ao qual o manipulador atual está anexado na árvore React.
+* [`defaultPrevented`](https://developer.mozilla.org/en-US/docs/Web/API/Event/defaultPrevented): Um booleano. Retorna se `preventDefault` foi chamado.
+* [`eventPhase`](https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase): Um número. Retorna em qual fase o evento está atualmente.
+* [`isTrusted`](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted): Um booleano. Retorna se o evento foi iniciado pelo usuário.
+* [`target`](https://developer.mozilla.org/en-US/docs/Web/API/Event/target): Um nó DOM. Retorna o nó no qual o evento ocorreu (que pode ser um filho distante).
+* [`timeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp): Um número. Retorna o tempo em que o evento ocorreu.
-Additionally, React event objects provide these properties:
+Além disso, os objetos de evento do React fornecem essas propriedades:
-* `nativeEvent`: A DOM [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). The original browser event object.
+* `nativeEvent`: Um [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) DOM. O objeto original do evento do 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:
+Os objetos de evento do React implementam alguns dos métodos padrão do [`Event`](https://developer.mozilla.org/en-US/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/en-US/docs/Web/API/Event/preventDefault): Impede a ação padrão do navegador para o evento.
+* [`stopPropagation()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation): Interrompe a propagação do evento através da árvore React.
-Additionally, React event objects provide these methods:
+Além disso, os objetos de evento do React fornecem esses 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()`: Retorna um valor booleano indicando se `preventDefault` foi chamado.
+* `isPropagationStopped()`: Retorna um valor booleano indicando se `stopPropagation` foi chamado.
+* `persist()`: Não usado com React DOM. Com React Native, chame isso para ler as propriedades do evento após o evento.
+* `isPersistent()`: Não usado com React DOM. Com React Native, retorna se `persist` foi chamado.
-#### Caveats {/*react-event-object-caveats*/}
+#### Ressalvas {/*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).
+* Os valores de `currentTarget`, `eventPhase`, `target`, e `type` refletem os valores que seu código React espera. Nos bastidores, o React anexa manipuladores de eventos na raiz, mas isso não é refletido nos objetos de evento do React. Por exemplo, `e.currentTarget` pode não ser o mesmo que o `e.nativeEvent.currentTarget` subjacente. Para eventos polyfilled, `e.type` (tipo de evento React) pode diferir de `e.nativeEvent.type` (tipo subjacente).
---
-### `AnimationEvent` handler function {/*animationevent-handler*/}
+### Função de manipulador de evento `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.
+Um tipo de manipulador de eventos para os [eventos de animação CSS](https://developer.mozilla.org/en-US/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:
+* `e`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`AnimationEvent`](https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent):
* [`animationName`](https://developer.mozilla.org/en-US/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)
---
-### `ClipboardEvent` handler function {/*clipboadevent-handler*/}
+### Função de manipulador de evento `ClipboardEvent` {/*clipboadevent-handler*/}
-An event handler type for the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) events.
+Um tipo de manipulador de eventos para os eventos da [Clipboard API](https://developer.mozilla.org/en-US/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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`ClipboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent):
* [`clipboardData`](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/clipboardData)
---
-### `CompositionEvent` handler function {/*compositionevent-handler*/}
+### Função de manipulador de evento `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.
+Um tipo de manipulador de eventos para os eventos de [editor de método de entrada (IME)](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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`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*/}
+### Função de manipulador de evento `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.
+Um tipo de manipulador de eventos para os eventos da [HTML Drag and Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API).
```js
<>
@@ -408,7 +408,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
+ Fonte de arrasto
{ e.preventDefault(); console.log('onDragOver'); }}
onDrop={e => console.log('onDrop')}
>
- Drop target
+ Alvo de soltura
>
```
-#### 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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`DragEvent`](https://developer.mozilla.org/en-US/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:
+ Também inclui as propriedades herdadas do [`MouseEvent`](https://developer.mozilla.org/en-US/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)
@@ -446,16 +446,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:
+ Também inclui as propriedades herdadas do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Função de manipulador de evento `FocusEvent` {/*focusevent-handler*/}
-An event handler type for the focus events.
+Um tipo de manipulador de eventos para os eventos de foco.
```js
```
-[See an example.](#handling-focus-events)
+[Veja um exemplo.](#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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`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:
+ Também inclui as propriedades herdadas do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Função de manipulador de evento `Event` {/*event-handler*/}
-An event handler type for generic events.
+Um tipo de manipulador para 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`: Um [objeto de evento do React](#react-event-object) sem propriedades adicionais.
---
-### `InputEvent` handler function {/*inputevent-handler*/}
+### Função de manipulador de evento `InputEvent` {/*inputevent-handler*/}
-An event handler type for the `onBeforeInput` event.
+Um tipo de manipulador de eventos para o 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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`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*/}
+### Função de manipulador de evento `KeyboardEvent` {/*keyboardevent-handler*/}
-An event handler type for keyboard events.
+Um tipo de manipulador de eventos para eventos de teclado.
```js
```
-[See an example.](#handling-keyboard-events)
+[Veja um exemplo.](#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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`KeyboardEvent`](https://developer.mozilla.org/en-US/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)
@@ -533,16 +533,16 @@ An event handler type for keyboard events.
* [`shiftKey`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/shiftKey)
* [`which`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ Também inclui as propriedades herdadas do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Função de manipulador de evento `MouseEvent` {/*mouseevent-handler*/}
-An event handler type for mouse events.
+Um tipo de manipulador de eventos para eventos de mouse.
```js
```
-[See an example.](#handling-mouse-events)
+[Veja um exemplo.](#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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`MouseEvent`](https://developer.mozilla.org/en-US/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)
@@ -577,16 +577,16 @@ An event handler type for mouse events.
* [`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:
+ Também inclui as propriedades herdadas do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Função de manipulador de evento `PointerEvent` {/*pointerevent-handler*/}
-An event handler type for [pointer events.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
+Um tipo de manipulador de eventos para [eventos de ponteiro.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
```js
```
-[See an example.](#handling-pointer-events)
+[Veja um exemplo.](#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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`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)
@@ -614,7 +614,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:
+ Também inclui as propriedades herdadas do [`MouseEvent`](https://developer.mozilla.org/en-US/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)
@@ -633,16 +633,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:
+ Também inclui as propriedades herdadas do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Função de manipulador de evento `TouchEvent` {/*touchevent-handler*/}
-An event handler type for [touch events.](https://developer.mozilla.org/en-US/docs/Web/API/Touch_events)
+Um tipo de manipulador de eventos para [eventos de toque.](https://developer.mozilla.org/en-US/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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`TouchEvent`](https://developer.mozilla.org/en-US/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)
@@ -665,16 +665,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:
+ Também inclui as propriedades herdadas do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Função de manipulador de evento `TransitionEvent` {/*transitionevent-handler*/}
-An event handler type for the CSS transition events.
+Um tipo de manipulador de eventos para os eventos de transição 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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`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*/}
+### Função de manipulador de evento `UIEvent` {/*uievent-handler*/}
-An event handler type for generic UI events.
+Um tipo de manipulador de eventos para eventos genéricos de UI.
```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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Função de manipulador de evento `WheelEvent` {/*wheelevent-handler*/}
-An event handler type for the `onWheel` event.
+Um tipo de manipulador de eventos para o 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`: Um [objeto de evento do React](#react-event-object) com essas propriedades extras do [`WheelEvent`](https://developer.mozilla.org/en-US/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:
+ Também inclui as propriedades herdadas do [`MouseEvent`](https://developer.mozilla.org/en-US/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)
@@ -745,37 +745,36 @@ An event handler type for the `onWheel` event.
* [`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)
- It also includes the inherited [`UIEvent`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent) properties:
+ Também inclui as propriedades herdadas do [`UIEvent`](https://developer.mozilla.org/en-US/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*/}
+### Aplicando 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:
+No React, você especifica uma classe CSS com [`className`.](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) Funciona como o atributo `class` em HTML:
```js
```
-Then you write the CSS rules for it in a separate CSS file:
+Então, você escreve as regras CSS para isso em um arquivo CSS separado:
```css
-/* In your CSS */
+/* No seu 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.
+O React não prescreve como você deve adicionar arquivos CSS. No caso mais simples, você adicionará uma tag [`
`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) ao seu HTML. Se você usar uma ferramenta de build ou um framework, consulte sua documentação para aprender como adicionar um arquivo CSS ao seu projeto.
-Sometimes, the style values depend on data. Use the `style` attribute to pass some styles dynamically:
+Às vezes, os valores de estilo dependem de dados. Use o atributo `style` para passar alguns estilos dinamicamente:
```js {3-6}
-
-```js src/App.js
-import Avatar from './Avatar.js';
-
-const user = {
- name: 'Hedy Lamarr',
- imageUrl: 'https://i.imgur.com/yXOvdOSs.jpg',
- imageSize: 90,
-};
-
-export default function App() {
- return
;
-}
-```
-
-```js src/Avatar.js active
-export default function Avatar({ user }) {
- return (
-
- );
-}
-```
-
-```css src/styles.css
-.avatar {
- border-radius: 50%;
-}
-```
-
-
-
-
-
-#### How to apply multiple CSS classes conditionally? {/*how-to-apply-multiple-css-classes-conditionally*/}
-
-To apply CSS classes conditionally, you need to produce the `className` string yourself using JavaScript.
-
-For example, `className={'row ' + (isSelected ? 'selected': '')}` will produce either `className="row"` or `className="row selected"` depending on whether `isSelected` is `true`.
-
-To make this more readable, you can use a tiny helper library like [`classnames`:](https://github.com/JedWatson/classnames)
-
-```js
-import cn from 'classnames';
-
-function Row({ isSelected }) {
- return (
-
- ...
-
- );
-}
-```
-
-It is especially convenient if you have multiple conditional classes:
-
-```js
-import cn from 'classnames';
-
-function Row({ isSelected, size }) {
- return (
-
- ...
-
- );
-}
-```
-
-
-
----
-
-### Manipulating a DOM node with a 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.
-
-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:
-
-```js {7}
-import { useRef } from 'react';
-
-export default function Form() {
- const inputRef = useRef(null);
- // ...
- return (
-
- // ...
-```
-
-React will put the DOM node into `inputRef.current` after it's been rendered to the screen.
-
-
-
-```js
-import { useRef } from 'react';
-
-export default function Form() {
- const inputRef = useRef(null);
-
- function handleClick() {
- inputRef.current.focus();
- }
-
- return (
- <>
-
-
- Focus the input
-
- >
- );
-}
-```
-
-
-
-Read more about [manipulating DOM with refs](/learn/manipulating-the-dom-with-refs) and [check out more examples.](/reference/react/useRef#examples-dom)
-
-For more advanced use cases, the `ref` attribute also accepts a [callback function.](#ref-callback)
-
----
-
-### Dangerously setting the inner HTML {/*dangerously-setting-the-inner-html*/}
-
-You can pass a raw HTML string to an element like so:
-
-```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.**
-
-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:
-
-
-
-```js
-import { useState } from 'react';
-import MarkdownPreview from './MarkdownPreview.js';
-
-export default function MarkdownEditor() {
- const [postContent, setPostContent] = useState('_Hello,_ **Markdown**!');
- return (
- <>
-
- Enter some markdown:
-
-
-
- >
- );
-}
-```
-
-```js src/MarkdownPreview.js active
-import { Remarkable } from 'remarkable';
-
-const md = new Remarkable();
-
-function renderMarkdownToHTML(markdown) {
- // This is ONLY safe because the output HTML
- // is shown to the same user, and because you
- // trust this Markdown parser to not have bugs.
- const renderedHTML = md.render(markdown);
- return {__html: renderedHTML};
-}
-
-export default function MarkdownPreview({ markdown }) {
- const markup = renderMarkdownToHTML(markdown);
- return
;
-}
-```
-
-```json package.json
-{
- "dependencies": {
- "react": "latest",
- "react-dom": "latest",
- "react-scripts": "latest",
- "remarkable": "2.0.1"
- },
- "scripts": {
- "start": "react-scripts start",
- "build": "react-scripts build",
- "test": "react-scripts test --env=jsdom",
- "eject": "react-scripts eject"
- }
-}
-```
-
-```css
-textarea { display: block; margin-top: 5px; margin-bottom: 10px; }
-```
-
-
-
-The `{__html}` object should be created as close to where the HTML is generated as possible, like the above example does in the `renderMarkdownToHTML` function. This ensures that all raw HTML being used in your code is explicitly marked as such, and that only variables that you expect to contain HTML are passed to `dangerouslySetInnerHTML`. It is not recommended to create the object inline like `
`.
-
-To see why rendering arbitrary HTML is dangerous, replace the code above with this:
-
-```js {1-4,7,8}
-const post = {
- // Imagine this content is stored in the database.
- content: `
`
-};
-
-export default function MarkdownPreview() {
- // 🔴 SECURITY HOLE: passing untrusted input to 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.**
-
----
-
-### Handling mouse events {/*handling-mouse-events*/}
-
-This example shows some common [mouse events](#mouseevent-handler) and when they fire.
-
-
-
-```js
-export default function MouseExample() {
- return (
- console.log('onMouseEnter (parent)')}
- onMouseLeave={e => console.log('onMouseLeave (parent)')}
- >
- console.log('onClick (first button)')}
- onMouseDown={e => console.log('onMouseDown (first button)')}
- onMouseEnter={e => console.log('onMouseEnter (first button)')}
- onMouseLeave={e => console.log('onMouseLeave (first button)')}
- onMouseOver={e => console.log('onMouseOver (first button)')}
- onMouseUp={e => console.log('onMouseUp (first button)')}
- >
- First button
-
- console.log('onClick (second button)')}
- onMouseDown={e => console.log('onMouseDown (second button)')}
- onMouseEnter={e => console.log('onMouseEnter (second button)')}
- onMouseLeave={e => console.log('onMouseLeave (second button)')}
- onMouseOver={e => console.log('onMouseOver (second button)')}
- onMouseUp={e => console.log('onMouseUp (second button)')}
- >
- Second button
-
-
- );
-}
-```
-
-```css
-label { display: block; }
-input { margin-left: 10px; }
-```
-
-
-
----
-
-### Handling pointer events {/*handling-pointer-events*/}
-
-This example shows some common [pointer events](#pointerevent-handler) and when they fire.
-
-
-
-```js
-export default function PointerExample() {
- return (
- console.log('onPointerEnter (parent)')}
- onPointerLeave={e => console.log('onPointerLeave (parent)')}
- style={{ padding: 20, backgroundColor: '#ddd' }}
- >
-
console.log('onPointerDown (first child)')}
- onPointerEnter={e => console.log('onPointerEnter (first child)')}
- onPointerLeave={e => console.log('onPointerLeave (first child)')}
- onPointerMove={e => console.log('onPointerMove (first child)')}
- onPointerUp={e => console.log('onPointerUp (first child)')}
- style={{ padding: 20, backgroundColor: 'lightyellow' }}
- >
- First child
-
-
console.log('onPointerDown (second child)')}
- onPointerEnter={e => console.log('onPointerEnter (second child)')}
- onPointerLeave={e => console.log('onPointerLeave (second child)')}
- onPointerMove={e => console.log('onPointerMove (second child)')}
- onPointerUp={e => console.log('onPointerUp (second child)')}
- style={{ padding: 20, backgroundColor: 'lightblue' }}
- >
- Second child
-
-
- );
-}
-```
-
-```css
-label { display: block; }
-input { margin-left: 10px; }
-```
-
-
-
----
-
-### Handling focus events {/*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.
-
-
-
-```js
-export default function FocusExample() {
- return (
- {
- if (e.currentTarget === e.target) {
- console.log('focused parent');
- } else {
- console.log('focused child', e.target.name);
- }
- if (!e.currentTarget.contains(e.relatedTarget)) {
- // Not triggered when swapping focus between children
- console.log('focus entered parent');
- }
- }}
- onBlur={(e) => {
- if (e.currentTarget === e.target) {
- console.log('unfocused parent');
- } else {
- console.log('unfocused child', e.target.name);
- }
- if (!e.currentTarget.contains(e.relatedTarget)) {
- // Not triggered when swapping focus between children
- console.log('focus left parent');
- }
- }}
- >
-
- First name:
-
-
-
- Last name:
-
-
-
- );
-}
-```
-
-```css
-label { display: block; }
-input { margin-left: 10px; }
-```
-
-
-
----
-
-### Handling keyboard events {/*handling-keyboard-events*/}
-
-This example shows some common [keyboard events](#keyboardevent-handler) and when they fire.
-
-
-
-```js
-export default function KeyboardExample() {
- return (
-
- First name:
- console.log('onKeyDown:', e.key, e.code)}
- onKeyUp={e => console.log('onKeyUp:', e.key, e.code)}
- />
-
- );
-}
-```
-
-```css
-label { display: block; }
-input { margin-left: 10px; }
-```
-
-
+No exemplo acima, `style={{}}` não é uma sintaxe especial, mas um objeto regular `{}` dentro das chaves `style={ }` [JSX.](/learn/javascript-in-jsx-with-curly-braces) Recomend
\ No newline at end of file