Socket
Book a DemoInstallSign in
Socket

react-component-debug

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-component-debug

Debug component

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

React Component Debug

Simple component to debug a component.

Installation

npm install  react-component-debug

Usage

Use the Debug component in your component:

import React from 'react'
import Debug from 'react-component-debug'

class MyComponent extends React.Component {
  static defaultProps = {
    firstProp: 'Hello world' 
  }
  state = {
    firstState: 'Hello debug'
  }
  render() {
    return <Debug component={this}/>
  }
}

Webpack configuration for dev only

This component is intended to be used only in development. You can make this module available everywhere in your app as long with this configuration in webpack:

// webpack.config.js

var plugins = []

if (process.argv.indexOf('-p')) {
  plugins.push(new webpack.ProvidePlugin({Debug: 'react-component-debug'}))
}

module.exports = {
  // your config here
  plugins: plugins
}

Then you can use the module anywhere without having to require it. Be sure to clean your code before building it for prod.

Keywords

react

FAQs

Package last updated on 12 Feb 2016

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