Skip to content

Instantly share code, notes, and snippets.

@tmbtech
Forked from ryanflorence/react-logger.js
Created October 11, 2016 02:30
Show Gist options
  • Select an option

  • Save tmbtech/538b303da7b05b4d518f0faa9a9d5cd7 to your computer and use it in GitHub Desktop.

Select an option

Save tmbtech/538b303da7b05b4d518f0faa9a9d5cd7 to your computer and use it in GitHub Desktop.

Revisions

  1. @ryanflorence ryanflorence revised this gist Aug 12, 2016. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions react-logger.js
    Original file line number Diff line number Diff line change
    @@ -3,14 +3,14 @@ const setState = Component.prototype.setState
    Component.prototype.setState = function(nextState) {
    console.group(this.constructor.name)
    console.trace()
    console.log('shouldComponentUpdate', (
    this.shouldComponentUpdate &&
    this.shouldComponentUpdate(this.props, nextState)
    ))
    if (this.shouldComponentUpdate) {
    console.log('shouldComponentUpdate', (
    this.shouldComponentUpdate(this.props, nextState)
    ))
    }
    console.log('props', this.props)
    console.log('state', this.state)
    console.log('nextState', nextState)
    console.groupEnd(this.constructor.name)
    return setState.apply(this, arguments)
    }

    }
  2. @ryanflorence ryanflorence revised this gist Aug 12, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion react-logger.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ Component.prototype.setState = function(nextState) {
    this.shouldComponentUpdate(this.props, nextState)
    ))
    console.log('props', this.props)
    console.log('previousState', this.state)
    console.log('state', this.state)
    console.log('nextState', nextState)
    console.groupEnd(this.constructor.name)
    return setState.apply(this, arguments)
  3. @ryanflorence ryanflorence revised this gist Aug 12, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion react-logger.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,16 @@
    // put this at the top of your app
    const setState = Component.prototype.setState

    Component.prototype.setState = function(nextState) {
    console.group(this.constructor.name)
    console.trace()
    console.log('shouldComponentUpdate', (
    this.shouldComponentUpdate &&
    this.shouldComponentUpdate(this.props, nextState)
    ))
    console.log('props', this.props)
    console.log('previousState', this.state)
    console.log('nextState', nextState)
    console.groupEnd(this.constructor.name)
    return setState.apply(this, arguments)
    }

  4. @ryanflorence ryanflorence created this gist Aug 11, 2016.
    12 changes: 12 additions & 0 deletions react-logger.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    // put this at the top of your app
    const setState = Component.prototype.setState

    Component.prototype.setState = function(nextState) {
    console.group(this.constructor.name)
    console.trace()
    console.log('props', this.props)
    console.log('previousState', this.state)
    console.log('nextState', nextState)
    console.groupEnd(this.constructor.name)
    return setState.apply(this, arguments)
    }