React Hook debugging hack

 •  Filed under react

Want a quick, no-lib hack to make it easier to track which instances of a hook are doing what? Use useRef.

function useMyHook() {
  const id = useRef(Math.floor(Math.random() * 1000));
  console.group(`useMyHook ${id.current}`);
  ...
  console.groupEnd();
}