react-debug

1.0.0 • Public • Published

react-debug

NPM version build status Test coverage Downloads

Debug module for react classes. Calls debug under the hood with the namespace set based on the displayName property of your class.

Installation

npm install react-debug

Usage

var debug = require('react-debug');
var react = require('react');
 
react.createClass({
  displayName: 'myClass',
  getInitialState: getInitialState,
  render: render
});
 
function getInitialState() {
  return {
    foo: 'bar',
    bin: 'baz'
  }
}
 
function render() {
  debug(this, 'render', this.state);
  // => class:myClass render [object]
}

Debug

To enable react-debug in the browser type in the console:

localStorage.debug = '*';

API

debug([ctx], msg)

Pass in a context to retrieve the displayName property from the react class. If no context is provided we default to just using class.

debug(react.createClass({displayName: 'baz'}), 'foobar');
// => class:baz foobar
 
debug('barbar');
// => class barbar

License

MIT

Package Sidebar

Install

npm i react-debug

Weekly Downloads

71

Version

1.0.0

License

MIT

Last publish

Collaborators

  • yoshuawuyts