react-debug
v1.0.0
Published
Debug module for react classes
Downloads
37
Maintainers
Readme
react-debug
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