react-debug

Debug module for react classes

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
react-debug
501.0.09 years ago9 years agoMinified + gzip package size for react-debug in KB

Readme

react-debug
!NPM versionnpm-imagenpm-url !build statustravis-imagetravis-url !Test coveragecoveralls-imagecoveralls-url !Downloadsdownloads-imagedownloads-url
Debug module for react classes. Calls debugdebug 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