` DOM node is removed, React will call your the cleanup function returned from the callback.
+Когда DOM-узел `
` будет добавлен на экран, React вызовет вашу функцию обратного вызова `ref` с DOM-узлом `node` в качестве аргумента. Когда DOM-узел `
` будет удален, React вызовет функцию очистки, возвращенную из обратного вызова.
-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 также будет вызывать вашу функцию обратного вызова `ref` всякий раз, когда вы передаете *другую* функцию обратного вызова `ref`. В приведенном выше примере `(node) => { ... }` является другой функцией при каждом рендере. Когда ваш компонент повторно рендерится, *предыдущая* функция будет вызвана с `null` в качестве аргумента, а *следующая* функция будет вызвана с DOM-узлом.
-#### Parameters {/*ref-callback-parameters*/}
+#### Параметры {/*ref-callback-parameters*/}
-* `node`: A DOM node. React will pass you the DOM node when the ref gets attached. Unless you pass the same function reference for the `ref` callback on every render, the callback will get temporarily cleanup and re-create during every re-render of the component.
+* `node`: DOM-узел. React передаст вам DOM-узел при подключении `ref`. Если вы не передаете одну и ту же ссылку на функцию для обратного вызова `ref` при каждом рендере, обратный вызов будет временно очищен и пересоздан во время каждого повторного рендеринга компонента.
-#### React 19 added cleanup functions for `ref` callbacks. {/*react-19-added-cleanup-functions-for-ref-callbacks*/}
+#### React 19 добавил функции очистки для обратных вызовов `ref`. {/*react-19-added-cleanup-functions-for-ref-callbacks*/}
-To support backwards compatibility, if a cleanup function is not returned from the `ref` callback, `node` will be called with `null` when the `ref` is detached. This behavior will be removed in a future version.
+Для обеспечения обратной совместимости, если функция очистки не возвращается из обратного вызова `ref`, `node` будет вызван с `null` при отсоединении `ref`. Это поведение будет удалено в будущей версии.
-#### Returns {/*returns*/}
+#### Возвращает {/*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. This behavior will be removed in a future version.
+* **необязательно** `функция очистки`: Когда `ref` отсоединяется, React вызовет функцию очистки. Если функция не возвращается обратным вызовом `ref`, React вызовет обратный вызов снова с `null` в качестве аргумента при отсоединении `ref`. Это поведение будет удалено в будущей версии.
-#### Caveats {/*caveats*/}
+#### Оговорки {/*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 no 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.
+* Когда включен Strict Mode, React **выполнит один дополнительный цикл настройки+очистки только для разработки** перед первой реальной настройкой. Это стресс-тест, который гарантирует, что ваша логика очистки "отражает" вашу логику настройки и что она останавливает или отменяет все, что делает настройка. Если это вызывает проблему, реализуйте функцию очистки.
+* Когда вы передаете *другую* функцию обратного вызова `ref`, React вызовет функцию очистки *предыдущего* обратного вызова, если она предоставлена. Если функция очистки не определена, обратный вызов `ref` будет вызван с `null` в качестве аргумента. *Следующая* функция будет вызвана с DOM-узлом.
---
-### React event object {/*react-event-object*/}
+### Объект события React {/*react-event-object*/}
-Your event handlers will receive a *React event object.* It is also sometimes known as a "synthetic event".
+Ваши обработчики событий получат *объект события React*. Его также иногда называют "синтетическим событием".
```js
{
- console.log(e); // React event object
+ console.log(e); // Объект события React
}} />
```
-It conforms to the same standard as the underlying DOM events, but fixes some browser inconsistencies.
+Он соответствует тому же стандарту, что и базовые события DOM, но исправляет некоторые несоответствия браузеров.
-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`.
+Некоторые события React не сопоставляются напрямую с нативными событиями браузера. Например, в `onMouseLeave` `e.nativeEvent` будет указывать на событие `mouseout`. Конкретное сопоставление не является частью публичного API и может измениться в будущем. Если вам по какой-либо причине нужно базовое событие браузера, прочитайте его из `e.nativeEvent`.
-#### Properties {/*react-event-object-properties*/}
+#### Свойства {/*react-event-object-properties*/}
-React event objects implement some of the standard [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) properties:
+Объекты событий React реализуют некоторые стандартные свойства [`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): Булево значение. Возвращает, происходит ли всплытие события через DOM.
+* [`cancelable`](https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable): Булево значение. Возвращает, можно ли отменить событие.
+* [`currentTarget`](https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget): DOM-узел. Возвращает узел, к которому прикреплен текущий обработчик в дереве React.
+* [`defaultPrevented`](https://developer.mozilla.org/en-US/docs/Web/API/Event/defaultPrevented): Булево значение. Возвращает, был ли вызван `preventDefault`.
+* [`eventPhase`](https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase): Число. Возвращает, в какой фазе находится событие.
+* [`isTrusted`](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted): Булево значение. Возвращает, было ли событие инициировано пользователем.
+* [`target`](https://developer.mozilla.org/en-US/docs/Web/API/Event/target): DOM-узел. Возвращает узел, на котором произошло событие (который может быть далеким потомком).
+* [`timeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp): Число. Возвращает время, когда произошло событие.
-Additionally, React event objects provide these properties:
+Кроме того, объекты событий React предоставляют следующие свойства:
-* `nativeEvent`: A DOM [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). The original browser event object.
+* `nativeEvent`: DOM [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). Исходный объект события браузера.
-#### Methods {/*react-event-object-methods*/}
+#### Методы {/*react-event-object-methods*/}
-React event objects implement some of the standard [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) methods:
+Объекты событий React реализуют некоторые стандартные методы [`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): Предотвращает действие браузера по умолчанию для события.
+* [`stopPropagation()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation): Останавливает распространение события через дерево React.
-Additionally, React event objects provide these methods:
+Кроме того, объекты событий React предоставляют следующие методы:
-* `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()`: Возвращает булево значение, указывающее, был ли вызван `preventDefault`.
+* `isPropagationStopped()`: Возвращает булево значение, указывающее, был ли вызван `stopPropagation`.
+* `persist()`: Не используется с React DOM. С React Native вызовите этот метод для чтения свойств события после события.
+* `isPersistent()`: Не используется с React DOM. С React Native возвращает, был ли вызван `persist`.
-#### Caveats {/*react-event-object-caveats*/}
+#### Оговорки {/*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).
+* Значения `currentTarget`, `eventPhase`, `target` и `type` отражают значения, которые ожидает ваш код React. Внутренне React прикрепляет обработчики событий к корневому узлу, но это не отражается в объектах событий React. Например, `e.currentTarget` может не совпадать с базовым `e.nativeEvent.currentTarget`. Для полифильных событий `e.type` (тип события React) может отличаться от `e.nativeEvent.type` (базовый тип).
---
-### `AnimationEvent` handler function {/*animationevent-handler*/}
+### Функция обработчика `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.
+Тип обработчика событий для событий [CSS-анимации](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations).
```js
```
-#### Parameters {/*animationevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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*/}
+### Функция обработчика `ClipboardEvent` {/*clipboadevent-handler*/}
-An event handler type for the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) events.
+Тип обработчика событий для событий [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API).
```js
```
-#### Parameters {/*clipboadevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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*/}
+### Функция обработчика `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.
+Тип обработчика событий для событий [редактора метода ввода (IME)](https://developer.mozilla.org/en-US/docs/Glossary/Input_method_editor).
```js
```
-#### Parameters {/*compositionevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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*/}
+### Функция обработчика `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.
+Тип обработчика событий для [API перетаскивания HTML](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API).
```js
<>
@@ -406,7 +406,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
+ Источник перетаскивания
{ e.preventDefault(); console.log('onDragOver'); }}
onDrop={e => console.log('onDrop')}
>
- Drop target
+ Цель перетаскивания
>
```
-#### Parameters {/*dragevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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:
+ Он также включает унаследованные свойства [`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)
@@ -444,16 +444,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:
+ Он также включает унаследованные свойства [`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*/}
+### Функция обработчика `FocusEvent` {/*focusevent-handler*/}
-An event handler type for the focus events.
+Тип обработчика событий для событий фокуса.
```js
```
-[See an example.](#handling-focus-events)
+[См. пример.](#handling-focus-events)
-#### Parameters {/*focusevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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:
+ Он также включает унаследованные свойства [`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*/}
+### Функция обработчика `Event` {/*event-handler*/}
-An event handler type for generic events.
+Тип обработчика событий для общих событий.
-#### Parameters {/*event-handler-parameters*/}
+#### Параметры {/*event-handler-parameters*/}
-* `e`: A [React event object](#react-event-object) with no additional properties.
+* `e`: [Объект события React](#react-event-object) без дополнительных свойств.
---
-### `InputEvent` handler function {/*inputevent-handler*/}
+### Функция обработчика `InputEvent` {/*inputevent-handler*/}
-An event handler type for the `onBeforeInput` event.
+Тип обработчика событий для события `onBeforeInput`.
```js
console.log('onBeforeInput')} />
```
-#### Parameters {/*inputevent-handler-parameters*/}
+####Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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*/}
+### Функция обработчика `KeyboardEvent` {/*keyboardevent-handler*/}
-An event handler type for keyboard events.
+Тип обработчика событий для событий клавиатуры.
```js
```
-[See an example.](#handling-keyboard-events)
+[См. пример.](#handling-keyboard-events)
-#### Parameters {/*keyboardevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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)
@@ -531,16 +531,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:
+ Он также включает унаследованные свойства [`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*/}
+### Функция обработчика `MouseEvent` {/*mouseevent-handler*/}
-An event handler type for mouse events.
+Тип обработчика событий для событий мыши.
```js
```
-[See an example.](#handling-mouse-events)
+[См. пример.](#handling-mouse-events)
-#### Parameters {/*mouseevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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)
@@ -575,16 +575,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:
+ Он также включает унаследованные свойства [`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*/}
+### Функция обработчика `PointerEvent` {/*pointerevent-handler*/}
-An event handler type for [pointer events.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
+Тип обработчика событий для [событий указателя.](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events)
```js
```
-[See an example.](#handling-pointer-events)
+[См. пример.](#handling-pointer-events)
-#### Parameters {/*pointerevent-handler-parameters*/}
+#### Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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)
@@ -612,7 +612,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:
+ Он также включает унаследованные свойства [`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)
@@ -631,16 +631,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:
+ Он также включает унаследованные свойства [`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*/}
+### Функция обработчика `TouchEvent` {/*touchevent-handler*/}
-An event handler type for [touch events.](https://developer.mozilla.org/en-US/docs/Web/API/Touch_events)
+Тип обработчика событий для [событий касания.](https://developer.mozilla.org/en-US/docs/Web/API/Touch_events)
```js
```
-#### Parameters {/*touchevent-handler-parameters*/}
+####Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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)
@@ -663,16 +663,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:
+ Он также включает унаследованные свойства [`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*/}
+### Функция обработчика `TransitionEvent` {/*transitionevent-handler*/}
-An event handler type for the CSS transition events.
+Тип обработчика событий для событий [CSS-переходов](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions).
```js
```
-#### Parameters {/*transitionevent-handler-parameters*/}
+####Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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*/}
+### Функция обработчика `UIEvent` {/*uievent-handler*/}
-An event handler type for generic UI events.
+Тип обработчика событий для общих событий пользовательского интерфейса.
```js
```
-#### Parameters {/*uievent-handler-parameters*/}
+####Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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*/}
+### Функция обработчика `WheelEvent` {/*wheelevent-handler*/}
-An event handler type for the `onWheel` event.
+Тип обработчика событий для события `onWheel`.
```js
```
-#### Parameters {/*wheelevent-handler-parameters*/}
+####Параметры {/*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`: [Объект события React](#react-event-object) с дополнительными свойствами [`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:
+ Он также включает унаследованные свойства [`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,35 +745,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:
+ Он также включает унаследованные свойства [`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*/}
+## Использование {/*usage*/}
-### Applying CSS styles {/*applying-css-styles*/}
+### Применение 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:
+В React вы указываете CSS-класс с помощью [`className`.](https://developer.mozilla.org/ru/docs/Web/API/Element/className) Он работает так же, как атрибут `class` в HTML:
```js
```
-Then you write the CSS rules for it in a separate CSS file:
+Затем вы пишете CSS-правила для него в отдельном CSS-файле:
```css
-/* In your CSS */
+/* В вашем 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 не предписывает, как добавлять CSS-файлы. В простейшем случае вы добавите тег [`
`](https://developer.mozilla.org/ru/docs/Web/HTML/Element/link) в ваш HTML. Если вы используете сборщик или фреймворк, обратитесь к его документации, чтобы узнать, как добавить CSS-файл в ваш проект.
-Sometimes, the style values depend on data. Use the `style` attribute to pass some styles dynamically:
+Иногда значения стилей зависят от данных. Используйте атрибут `style`, чтобы передавать некоторые стили динамически:
```js {3-6}
@@ -830,13 +830,13 @@ export default function Avatar({ user }) {
-#### How to apply multiple CSS classes conditionally? {/*how-to-apply-multiple-css-classes-conditionally*/}
+#### Как условно применять несколько CSS-классов? {/*how-to-apply-multiple-css-classes-conditionally*/}
-To apply CSS classes conditionally, you need to produce the `className` string yourself using JavaScript.
+Чтобы условно применять CSS-классы, вам нужно самостоятельно сформировать строку `className` с помощью JavaScript.
-For example, `className={'row ' + (isSelected ? 'selected': '')}` will produce either `className="row"` or `className="row selected"` depending on whether `isSelected` is `true`.
+Например, `className={'row ' + (isSelected ? 'selected': '')}` создаст либо `className="row"`, либо `className="row selected"` в зависимости от того, равно ли `isSelected` значению `true`.
-To make this more readable, you can use a tiny helper library like [`classnames`:](https://github.com/JedWatson/classnames)
+Чтобы сделать это более читаемым, вы можете использовать небольшую вспомогательную библиотеку, такую как [`classnames`:](https://github.com/JedWatson/classnames)
```js
import cn from 'classnames';
@@ -850,7 +850,7 @@ function Row({ isSelected }) {
}
```
-It is especially convenient if you have multiple conditional classes:
+Это особенно удобно, если у вас несколько условных классов:
```js
import cn from 'classnames';
@@ -872,11 +872,11 @@ function Row({ isSelected, size }) {
---
-### Manipulating a DOM node with a ref {/*manipulating-a-dom-node-with-a-ref*/}
+### Манипулирование DOM-узлом с помощью 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.
+Иногда вам нужно получить браузерный DOM-узел, связанный с тегом в JSX. Например, если вы хотите сфокусироваться на ` ` при нажатии кнопки, вам нужно вызвать [`focus()`](https://developer.mozilla.org/ru/docs/Web/API/HTMLElement/focus) для браузерного DOM-узла ` `.
-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:
+Чтобы получить браузерный DOM-узел для тега, [объявите ref](/reference/react/useRef) и передайте его как атрибут `ref` этому тегу:
```js {7}
import { useRef } from 'react';
@@ -889,7 +889,7 @@ export default function Form() {
// ...
```
-React will put the DOM node into `inputRef.current` after it's been rendered to the screen.
+React поместит DOM-узел в `inputRef.current` после его отображения на экране.
@@ -916,24 +916,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)
+Подробнее о [манипулировании DOM с помощью refs](/learn/manipulating-the-dom-with-refs) и [других примерах.](/reference/react/useRef#examples-dom)
-For more advanced use cases, the `ref` attribute also accepts a [callback function.](#ref-callback)
+Для более сложных случаев атрибут `ref` также принимает [функцию-колбэк.](#ref-callback)
---
-### Dangerously setting the inner HTML {/*dangerously-setting-the-inner-html*/}
+### Опасное задание внутреннего HTML {/*dangerously-setting-the-inner-html*/}
-You can pass a raw HTML string to an element like so:
+Вы можете передать строку с необработанным HTML элементу следующим образом:
```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.**
+**Это опасно. Как и в случае со встроенным свойством DOM [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML), вы должны проявлять крайнюю осторожность! Если разметка не поступает из полностью доверенного источника, очень легко создать уязвимость [XSS](https://ru.wikipedia.org/wiki/%D0%9C%D0%B5%D0%B6%D1%81%D0%B0%D0%B9%D1%82%D0%BE%D0%B2%D0%BE%D0%B5_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5) таким образом.**
-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:
+Например, если вы используете библиотеку Markdown, которая преобразует Markdown в HTML, вы доверяете тому, что ее парсер не содержит ошибок, и пользователь видит только свой ввод, вы можете отобразить полученный HTML следующим образом:
@@ -1001,9 +1001,9 @@ 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 `
`.
+Объект `{__html}` следует создавать как можно ближе к месту генерации HTML, как это делается в приведенном выше примере в функции `renderMarkdownToHTML`. Это гарантирует, что весь необработанный HTML, используемый в вашем коде, явно помечен как таковой, и что в `dangerouslySetInnerHTML` передаются только переменные, которые, как вы ожидаете, содержат HTML. Не рекомендуется создавать объект непосредственно, например `
`.
-To see why rendering arbitrary HTML is dangerous, replace the code above with this:
+Чтобы увидеть, почему рендеринг произвольного HTML опасен, замените приведенный выше код на этот:
```js {1-4,7,8}
const post = {
@@ -1018,13 +1018,13 @@ export default function MarkdownPreview() {
}
```
-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.**
+Код, встроенный в HTML, будет выполнен. Хакер может использовать эту дыру в безопасности для кражи информации пользователя или для выполнения действий от его имени. **Используйте `dangerouslySetInnerHTML` только с доверенными и очищенными данными.**
---
-### Handling mouse events {/*handling-mouse-events*/}
+### Обработка событий мыши {/*handling-mouse-events*/}
-This example shows some common [mouse events](#mouseevent-handler) and when they fire.
+Этот пример показывает некоторые распространенные [события мыши](#mouseevent-handler) и когда они срабатывают.
@@ -1069,9 +1069,9 @@ input { margin-left: 10px; }
---
-### Handling pointer events {/*handling-pointer-events*/}
+### Обработка событий указателя {/*handling-pointer-events*/}
-This example shows some common [pointer events](#pointerevent-handler) and when they fire.
+Этот пример показывает некоторые распространенные [события указателя](#pointerevent-handler) и когда они срабатывают.
@@ -1117,9 +1117,9 @@ input { margin-left: 10px; }
---
-### Handling focus events {/*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.
+В React [события фокуса](#focusevent-handler) всплывают. Вы можете использовать `currentTarget` и `relatedTarget`, чтобы различать, исходили ли события фокусировки или разфокусировки извне родительского элемента. Пример показывает, как обнаружить фокусировку на дочернем элементе, фокусировку на родительском элементе и как обнаружить вход или выход фокуса из всего поддерева.
@@ -1173,9 +1173,9 @@ input { margin-left: 10px; }
---
-### Handling keyboard events {/*handling-keyboard-events*/}
+### Обработка событий клавиатуры {/*handling-keyboard-events*/}
-This example shows some common [keyboard events](#keyboardevent-handler) and when they fire.
+Этот пример показывает некоторые распространенные [события клавиатуры](#keyboardevent-handler) и когда они срабатывают.