Skip to content

Commit 15cc1d9

Browse files
authored
Merge pull request #42 from reactjs/reference/hooks/useDebugValue
Translated useDebugValue
2 parents e76e5cf + 8ded496 commit 15cc1d9

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

src/content/reference/react/useDebugValue.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: useDebugValue
44

55
<Intro>
66

7-
`useDebugValue` is a React Hook that lets you add a label to a custom Hook in [React DevTools.](/learn/react-developer-tools)
7+
`useDebugValue` — хук React, які дазваляе дадаць пазнаку да ўласнага хука ў [React DevTools.](/learn/react-developer-tools)
88

99
```js
1010
useDebugValue(value, format?)
@@ -20,7 +20,7 @@ useDebugValue(value, format?)
2020
2121
### `useDebugValue(value, format?)` {/*usedebugvalue*/}
2222
23-
Call `useDebugValue` at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable debug value:
23+
Выклічце `useDebugValue` на верхнім узроўні вашага [ўласнага хука](/learn/reusing-logic-with-custom-hooks) каб паказаць прыдатнае да чытання значэнне:
2424
2525
```js
2626
import { useDebugValue } from 'react';
@@ -32,22 +32,22 @@ function useOnlineStatus() {
3232
}
3333
```
3434
35-
[See more examples below.](#usage)
35+
[Болей прыкладаў глядзіце ніжэй.](#usage)
3636
37-
#### Parameters {/*parameters*/}
37+
#### Параметры {/*parameters*/}
3838
39-
* `value`: The value you want to display in React DevTools. It can have any type.
40-
* **optional** `format`: A formatting function. When the component is inspected, React DevTools will call the formatting function with the `value` as the argument, and then display the returned formatted value (which may have any type). If you don't specify the formatting function, the original `value` itself will be displayed.
39+
* `value` — значэнне, якое вы хочаце паказваць у React DevTools. Яно можа мець любы тып.
40+
* **(неабавязковае)** `format` — функцыя фармаціравання. Пры даследаванні элемента, React DevTools выкліча функцыю фармаціравання, перадаўшы ў яе `value` у якасці аргумента, і пакажа адфармаціраванае значэнне, якое верне функцыя (яна прымае значэнне любога тыпу). Калі не задаваць функцыю фармаціравання, будзе паказана арыгінальнае значэнне `value`.
4141
42-
#### Returns {/*returns*/}
42+
#### Значэнні, якія вяртаюцца {/*returns*/}
4343
44-
`useDebugValue` does not return anything.
44+
`useDebugValue` нічога не вяртае.
4545
46-
## Usage {/*usage*/}
46+
## Выкарыстанне {/*usage*/}
4747
48-
### Adding a label to a custom Hook {/*adding-a-label-to-a-custom-hook*/}
48+
### Дадаванне пазнакі да ўласнага хука {/*adding-a-label-to-a-custom-hook*/}
4949
50-
Call `useDebugValue` at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable <CodeStep step={1}>debug value</CodeStep> for [React DevTools.](/learn/react-developer-tools)
50+
Выклічце `useDebugValue` на верхнім узроўні вашага [ўласнага хука](/learn/reusing-logic-with-custom-hooks) каб паказаць прыдатнае да чытання <CodeStep step={1}>значэнне для адладкі</CodeStep> для [React DevTools](/learn/react-developer-tools).
5151
5252
```js [[1, 5, "isOnline ? 'Online' : 'Offline'"]]
5353
import { useDebugValue } from 'react';
@@ -59,11 +59,11 @@ function useOnlineStatus() {
5959
}
6060
```
6161
62-
This gives components calling `useOnlineStatus` a label like `OnlineStatus: "Online"` when you inspect them:
62+
Гэта задасць кампаненту, які выклікае `useOnlineStatus`, пазнаку `OnlineStatus: "Online"` пры даследаванні яго:
6363
64-
![A screenshot of React DevTools showing the debug value](/images/docs/react-devtools-usedebugvalue.png)
64+
![Здымак экрана React DevTools, у якім паказваецца значэнне для адладкі](/images/docs/react-devtools-usedebugvalue.png)
6565
66-
Without the `useDebugValue` call, only the underlying data (in this example, `true`) would be displayed.
66+
Без выкліку `useDebugValue` будзе паказана толькі асноўнае значэнне (у дадзеным прыкладзе — `true`).
6767
6868
<Sandpack>
6969
@@ -103,20 +103,20 @@ function subscribe(callback) {
103103
104104
<Note>
105105
106-
Don't add debug values to every custom Hook. It's most valuable for custom Hooks that are part of shared libraries and that have a complex internal data structure that's difficult to inspect.
106+
Не дадавайце значэнні для адладкі кожнаму хуку. Іх карысна выкарыстоўваць у хуках, што з'яўляюцца часткай агульнай бібліятэкі і ў хуках са складанай унутранай структурай даных, якую можа быць складана даследаваць.
107107
108108
</Note>
109109
110110
---
111111
112-
### Deferring formatting of a debug value {/*deferring-formatting-of-a-debug-value*/}
112+
### Адтэрміноўка фармаціравання значэння для адладкі {/*deferring-formatting-of-a-debug-value*/}
113113
114-
You can also pass a formatting function as the second argument to `useDebugValue`:
114+
Вы заўсёды можаце перадаць функцыю фармаціравання ў якасці другога аргумента `useDebugValue`:
115115
116116
```js [[1, 1, "date", 18], [2, 1, "date.toDateString()"]]
117117
useDebugValue(date, date => date.toDateString());
118118
```
119119
120-
Your formatting function will receive the <CodeStep step={1}>debug value</CodeStep> as a parameter and should return a <CodeStep step={2}>formatted display value</CodeStep>. When your component is inspected, React DevTools will call this function and display its result.
120+
Вашая функцыя фармаціравання атрымае <CodeStep step={1}>значэнне для адладкі</CodeStep> ў якасці параметра і мае вярнуць <CodeStep step={2}>фармаціраванае значэнне</CodeStep>. Калі вы дасладуеце свой кампанент, React DevTools выклікае функцыю і паказвае вынік выканання.
121121
122-
This lets you avoid running potentially expensive formatting logic unless the component is actually inspected. For example, if `date` is a Date value, this avoids calling `toDateString()` on it for every render.
122+
Гэта дазваляе пазбегнуць выканання патэнцыйна складанай логікі фармаціравання да таго часу, як кампанент будзе даследавацца. Напрыклад, калі `date` мае тып Date, гэта пазбягае выканання `toDateString()` падчас кожнага перарэндэрынгу.

0 commit comments

Comments
 (0)