You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react/Profiler.md
+28-28
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: <Profiler>
4
4
5
5
<Intro>
6
6
7
-
`<Profiler>`lets you measure rendering performance of a React tree programmatically.
7
+
`<Profiler>`дає вам змогу програмно вимірювати продуктивність рендеру React-дерева.
8
8
9
9
```js
10
10
<Profiler id="App" onRender={onRender}>
@@ -18,55 +18,55 @@ title: <Profiler>
18
18
19
19
---
20
20
21
-
## Reference {/*reference*/}
21
+
## Опис {/*reference*/}
22
22
23
23
### `<Profiler>` {/*profiler*/}
24
24
25
-
Wrap a component tree in a `<Profiler>` to measure its rendering performance.
25
+
Обгорніть дерево компонентів у `<Profiler>`, щоб виміряти продуктивність його рендеру.
26
26
27
27
```js
28
28
<Profiler id="App" onRender={onRender}>
29
29
<App />
30
30
</Profiler>
31
31
```
32
32
33
-
#### Props {/*props*/}
33
+
#### Пропси {/*props*/}
34
34
35
-
*`id`: A string identifying the part of the UI you are measuring.
36
-
*`onRender`: An [`onRender` callback](#onrender-callback) that React calls every time components within the profiled tree update. It receives information about what was rendered and how much time it took.
35
+
*`id`: Стрічковий ідентифікатор тієї частини UI, продуктивність якої ви вимірюєте.
36
+
*`onRender`: [Функція зворотного виклику `onRender`](#onrender-callback), яку React викликає щоразу, коли компоненти всередині профільованого дерева оновлюються. Вона отримує інформацію про те, що було відрендерено і скільки часу це зайняло.
37
37
38
-
#### Caveats {/*caveats*/}
38
+
#### Застереження {/*caveats*/}
39
39
40
-
*Profiling adds some additional overhead, so**it is disabled in the production build by default.**To opt into production profiling, you need to enable a [special production build with profiling enabled.](https://fb.me/react-profiling)
40
+
*Профілювання створює додаткове навантаження, тому**початково воно вимкнене у збірці для впровадження (production).**Щоб профілювати у публічному середовищі, потрібно скористатися [спеціальною збіркою для впровадження з увімкненим профілюванням.](https://fb.me/react-profiling)
41
41
42
42
---
43
43
44
-
### `onRender` callback {/*onrender-callback*/}
44
+
### Функція зворотного виклику `onRender` {/*onrender-callback*/}
45
45
46
-
React will call your `onRender`callback with information about what was rendered.
46
+
React викличе вашу функцію зворотного виклику `onRender`з інформацією про те, що було відрендерено.
//Зберіть або виведіть дані про тривалість рендеру...
51
51
}
52
52
```
53
53
54
-
#### Parameters {/*onrender-parameters*/}
54
+
#### Параметри {/*onrender-parameters*/}
55
55
56
-
*`id`: The string`id`prop of the `<Profiler>` tree that has just committed. This lets you identify which part of the tree was committed if you are using multiple profilers.
57
-
*`phase`: `"mount"`, `"update"`or`"nested-update"`. This lets you know whether the tree has just been mounted for the first time or re-rendered due to a change in props, state, or Hooks.
58
-
*`actualDuration`: The number of milliseconds spent rendering the `<Profiler>`and its descendants for the current update. This indicates how well the subtree makes use of memoization (e.g.[`memo`](/reference/react/memo)and[`useMemo`](/reference/react/useMemo)). Ideally this value should decrease significantly after the initial mount as many of the descendants will only need to re-render if their specific props change.
59
-
*`baseDuration`: The number of milliseconds estimating how much time it would take to re-render the entire `<Profiler>`subtree without any optimizations. It is calculated by summing up the most recent render durations of each component in the tree. This value estimates a worst-case cost of rendering (e.g. the initial mount or a tree with no memoization). Compare`actualDuration`against it to see if memoization is working.
60
-
*`startTime`: A numeric timestamp for when React began rendering the current update.
61
-
*`commitTime`: A numeric timestamp for when React committed the current update. This value is shared between all profilers in a commit, enabling them to be grouped if desirable.
56
+
*`id`: Стрічковий проп`id`дерева `<Profiler>`, яке щойно було внесено (committed). Він дає вам змогу визначити, яку саме частину дерева було внесено, якщо ви використовуєте кілька профілювачів.
57
+
*`phase`: `"mount"`, `"update"`або`"nested-update"`. Дає змогу дізнатися, чи дерево було щойно змонтовано вперше або ж рендерено повторно через зміни в стані, пропсах чи хуках.
58
+
*`actualDuration`: Кількість мілісекунд, витрачених на рендеринг компонента `<Profiler>`і його дочірніх компонентів під час поточного оновлення. Вказує на те, наскільки ефективно піддерево використовує мемоїзацію (наприклад,[`memo`](/reference/react/memo)і[`useMemo`](/reference/react/useMemo)). В ідеалі, це значення повинно значно зменшитися після першого монтування, оскільки багато з дочірніх компонентів буде перерендерюватися лише за зміни пропсів.
59
+
*`baseDuration`: Кількість мілісекунд, яка відображає, скільки часу займе повторний рендер усього піддерева компонента `<Profiler>`без будь-якої оптимізації. Це значення розраховується як сума часу останніх рендерів кожного компонента в дереві. Воно показує найгірший сценарій рендерингу (наприклад, перше монтування або дерево без мемоїзації). Порівняйте`actualDuration`з ним, щоби перевірити, чи працює мемоїзація.
60
+
*`startTime`: Числове значення, яке вказує на момент часу, коли React почав рендеринг поточного оновлення.
61
+
*`commitTime`: Числове значення, яке вказує на момент часу, коли React вніс поточне оновлення. Це значення однакове в усіх профілювачів у коміті, що дає змогу згрупувати їх за потреби.
### Програмне вимірювання продуктивності рендерингу {/*measuring-rendering-performance-programmatically*/}
68
68
69
-
Wrap the`<Profiler>`component around a React tree to measure its rendering performance.
69
+
Обгорніть компонент`<Profiler>`навколо React-дерева, щоб визначити продуктивність його рендеру.
70
70
71
71
```js {2,4}
72
72
<App>
@@ -77,25 +77,25 @@ Wrap the `<Profiler>` component around a React tree to measure its rendering per
77
77
</App>
78
78
```
79
79
80
-
It requires two props: an `id` (string) and an `onRender` callback (function) which React calls any time a component within the tree "commits" an update.
80
+
Він потребує двох пропсів: `id` (стрічка) і функцію зворотного виклику `onRender`, яку React викличе, коли будь-який компонент всередині дерева "закомітить" (внесе) оновлення.
81
81
82
82
<Pitfall>
83
83
84
-
Profiling adds some additional overhead, so**it is disabled in the production build by default.**To opt into production profiling, you need to enable a [special production build with profiling enabled.](https://fb.me/react-profiling)
84
+
* Профілювання створює додаткове навантаження, тому**початково воно вимкнене у збірці для впровадження (production).**Щоб профілювати у публічному середовищі, потрібно скористатися [спеціальною збіркою для впровадження з увімкненим профілюванням.](https://fb.me/react-profiling)
85
85
86
86
</Pitfall>
87
87
88
88
<Note>
89
89
90
-
`<Profiler>`lets you gather measurements programmatically. If you're looking for an interactive profiler, try the Profiler tab in [React Developer Tools](/learn/react-developer-tools). It exposes similar functionality as a browser extension.
90
+
`<Profiler>`дає вам змогу збирати показники програмно. Якщо ви шукаєте інтерактивний профілювач, спробуйте вкладку Profiler в [Інструментах React розробника](/learn/react-developer-tools). Вона надає подібний функціонал як розширення для браузера.
91
91
92
92
</Note>
93
93
94
94
---
95
95
96
-
### Measuring different parts of the application {/*measuring-different-parts-of-the-application*/}
96
+
### Вимірювання продуктивності різних частин застосунку {/*measuring-different-parts-of-the-application*/}
97
97
98
-
You can use multiple `<Profiler>` components to measure different parts of your application:
98
+
Ви можете використовувати кілька компонентів `<Profiler>`, щоб виміряти продуктивність різних частин вашого застосунку:
99
99
100
100
```js {5,7}
101
101
<App>
@@ -108,7 +108,7 @@ You can use multiple `<Profiler>` components to measure different parts of your
108
108
</App>
109
109
```
110
110
111
-
You can also nest `<Profiler>` components:
111
+
Ви також можете вкладувати компоненти `<Profiler>`:
112
112
113
113
```js {5,7,9,12}
114
114
<App>
@@ -126,7 +126,7 @@ You can also nest `<Profiler>` components:
126
126
</App>
127
127
```
128
128
129
-
Although`<Profiler>`is a lightweight component, it should be used only when necessary. Each use adds some CPU and memory overhead to an application.
129
+
Хоча`<Profiler>`є легким компонентом, його слід використовувати лише за необхідності. Кожне його використання додає певне навантаження на CPU та пам’ять вашого застосунку.
0 commit comments