4

I am trying to inspect a React Hooks component in Dev Tools but regardless of component all my useState hooks show up as

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.

Here is how I setup each hook:

const [myHook, setMyHook] = useState(false);

Badrush
  • 1,079
  • 1
  • 13
  • 32
  • Looks like this is default behaviour unfortunately... https://github.com/facebook/react-devtools/issues/1334 – Badrush Jan 24 '20 at 16:48

1 Answers1

3

see 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]; 
} 
Community
  • 1
  • 1
muescha
  • 1,513
  • 2
  • 12
  • 22