Socket
Socket
Sign inDemoInstall

babel-plugin-react-hooks-debug-value

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
3
Maintainers
1
Install size
48.9 kB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 13 Aug 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc