1.0.0 • Published 10 years ago

react-debug v1.0.0

Weekly downloads
515
License
MIT
Repository
github
Last release
10 years ago

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