WIP dont update dygraph unless there are changes

pull/3268/head
Andrew Watkins 2018-04-12 11:14:53 -07:00
parent 083591dfa5
commit cf6afdbabe
1 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import shallowCompare from 'react-addons-shallow-compare'
import _ from 'lodash'
import NanoDate from 'nano-date'
@ -107,11 +106,12 @@ class Dygraph extends Component {
this.dygraph.resetZoom()
}
// Will cause componentDidUpdate to fire twice, currently. This could
// be reduced by returning false from within the reset conditional above,
// though that would be based on the assumption that props for timeRange
// will always change before those for data.
return shallowCompare(this, nextProps, nextState)
const arePropsEqual = _.isEqual(this.props, nextProps)
const areStatesEqual = _.isEqual(this.state, nextState)
const shouldUpdate = !arePropsEqual || !areStatesEqual
return shouldUpdate
}
componentDidUpdate() {