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
* `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.
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)
@@ -103,20 +103,20 @@ function subscribe(callback) {
103
103
104
104
<Note>
105
105
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.
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.
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