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: beta/src/content/apis/react/useDebugValue.md
+21-21Lines changed: 21 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: useDebugValue
4
4
5
5
<Intro>
6
6
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`es un Hook de React que te permite añadir una etiqueta a un Hook personalizado en las [herramientas de desarrollo de React.](/learn/react-developer-tools)
8
8
9
9
```js
10
10
useDebugValue(value, format?)
@@ -16,11 +16,11 @@ useDebugValue(value, format?)
16
16
17
17
---
18
18
19
-
## Usage {/*usage*/}
19
+
## Uso {/*usage*/}
20
20
21
-
### Adding a label to a custom Hook {/*adding-a-label-to-a-custom-hook*/}
21
+
### Añadir una etiqueta a un Hook personalizado {/*adding-a-label-to-a-custom-hook*/}
22
22
23
-
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)
23
+
Llama a `useDebugValue`en el primer nivel de tu [Hook personalizado](/learn/reusing-logic-with-custom-hooks) para mostrar un <CodeStep step={1}>valor de depuración</CodeStep> legible para las [herramientas de desarrollo de React.](/learn/react-developer-tools)
24
24
25
25
```js [[1, 5, "isOnline ? 'Online' : 'Offline'"]]
26
26
import { useDebugValue } from'react';
@@ -32,11 +32,11 @@ function useOnlineStatus() {
32
32
}
33
33
```
34
34
35
-
This gives components calling `useOnlineStatus`a label like`OnlineStatus:"Online"`when you inspect them:
35
+
Esto le da a los componentes que llamen a `useOnlineStatus`una etiqueta como`OnlineStatus:"Online"`cuando lo inspeccionas:
36
36
37
-

37
+

38
38
39
-
Without the `useDebugValue` call, only the underlying data (in this example, `true`) would be displayed.
39
+
Sin la llamada a `useDebugValue`, solo se mostrarán los datos subyacentes (en este ejemplo, `true`).
40
40
41
41
<Sandpack>
42
42
@@ -45,7 +45,7 @@ import { useOnlineStatus } from './useOnlineStatus.js';
@@ -76,31 +76,31 @@ function subscribe(callback) {
76
76
77
77
<Note>
78
78
79
-
We don't recommend adding 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.
79
+
No recomendamos añadir valores de depuración a cada Hook personalizado. Es más valioso para Hooks personalizados que son parte de bibliotecas compartidas y que tienen una estructura de datos compleja interna que es difícil de inspeccionar.
80
80
81
81
</Note>
82
82
83
83
---
84
84
85
-
### Deferring formatting of a debug value {/*deferring-formatting-of-a-debug-value*/}
85
+
### Aplazar el formateo de un valor de depuración {/*deferring-formatting-of-a-debug-value*/}
86
86
87
-
You can also pass a formatting function as the second argument to`useDebugValue`:
87
+
Puedes también pasar una función de formateo como segundo argumento para`useDebugValue`:
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 the formatting function and display its result.
93
+
Tu función de formateo recibirá el <CodeStep step={1}>valor de depuración</CodeStep> como parámetro y debe retornar un <CodeStep step={2}>valor de visualización formateado</CodeStep>. Cuando tu componente es inspeccionado, las herramientas de desarrollo de React llamarán a la función de formateo y mostrarán el resultado.
94
94
95
-
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 of your component.
95
+
Esto permite evitar ejecutar una lógica de formateo potencialmente costosa a no ser que el componente esté siendo inspeccionado. Por ejemplo, si`date`es un valor de fecha, evita llamar a`toDateString()`para cada renderizado del componente.
Call `useDebugValue`at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable debug value:
103
+
Llama a `useDebugValue`en el primer nivel de tu [Hook personalizado](/learn/reusing-logic-with-custom-hooks) para mostrar un valor de depuración legible:
104
104
105
105
```js
106
106
import { useDebugValue } from'react';
@@ -112,14 +112,14 @@ function useOnlineStatus() {
112
112
}
113
113
```
114
114
115
-
[See more examples above.](#usage)
115
+
[Más ejemplos arriba.](#usage)
116
116
117
-
#### Parameters {/*parameters*/}
117
+
#### Parámetros {/*parameters*/}
118
118
119
-
* `value`: The value you want to display in React DevTools. It can have any type.
120
-
* **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.
119
+
* `value`: El valor que quieres mostrar en las herramientas de desarrollo de React. Puede tener cualquier tipo.
120
+
* `format` **opcional**: Una función de formateo. Cuando se inspecciona el componente, las herramientas de desarrollo de React llamarán a la función de formateo con `value`como argumento, y mostrarán el valor formateado devuelto (que puede tener cualquier tipo). Si no especificas la función de formateo, se mostrará el mismo valor `value`original.
0 commit comments