šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

babel-plugin-react-hooks-debug-value

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-react-hooks-debug-value

Babel plugin to give React Hooks a label in DevTools

1.0.1
latest
Source
npm
Version published
Weekly downloads
9
80%
Maintainers
1
Weekly downloads
Ā 
Created
Source

babel-plugin-react-hooks-debug-value

Babel plugin to give React Hooks a label in DevTools.

With this plugin, it's clear in React DevTools which hook values correspond to which variables.

This is intended for development only.

Suppose you have this code:

const MyComp = () => {
  const [myState, setMyState] = useState(1);
  const [otherState, setOtherState] = React.useState(2);

  return <Ok />
}

You'll now see this:

after

Instead of this:

before `

since the code is transformed into this:

const useDebugValue2 = (...args) => {
  React.useDebugValue("otherState");
  return React.useState(...args);
};

const useDebugValue1 = (...args) => {
  React.useDebugValue("myState");
  return useState(...args);
};

const MyComp = () => {
  const [myState, setMyState] = useDebugValue1(1);
  const [otherState, setOtherState] = useDebugValue2(2);

  return React.createElement(Ok, null);
};

Install

npm add -D babel-plugin-react-hooks-debug-value

In your Babel config (scoping to your dev build somehow):

module.exports = {
  plugins: ['babel-plugin-react-hooks-debug-value']
}

Keywords

babel

FAQs

Package last updated on 13 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts