react-debug
!NPM versionnpm-imagenpm-url
!build statustravis-imagetravis-url
!Test coveragecoveralls-imagecoveralls-url
!Downloadsdownloads-imagedownloads-urlDebug module for react classes. Calls
debug
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 enablereact-debug
in the browser type in the console:
localStorage.debug = '*';
API
debug(ctx, msg)
Pass in a context to retrieve thedisplayName
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