[英]Chrome Dev Tools Shows all useState hooks with the name 'State'
I am trying to inspect a React Hooks component in Dev Tools but regardless of component all my useState hooks show up as我正在尝试检查开发工具中的 React Hooks 组件,但无论组件如何,我的所有 useState 钩子都显示为
Hooks
State: false
State: null
Effect: fn()
The false
values are correct but I can't figure out which hook is which since for some reason they won't display the hook variable name. false
值是正确的,但我无法弄清楚哪个钩子是哪个,因为出于某种原因,它们不会显示钩子变量名称。
Here is how I setup each hook:这是我设置每个钩子的方法:
const [myHook, setMyHook] = useState(false);
see https://stackoverflow.com/a/58579953/1930509见https://stackoverflow.com/a/58579953/1930509
const [item, setItem] = useStateWithLabel(2, "item");
function useStateWithLabel(initialValue, name) { const [value, setValue] = useState(initialValue); useDebugValue(`${name}: ${value}`); return [value, setValue]; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.