From cf6afdbabef2726c4171fad87ee60e58afb63599 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Thu, 12 Apr 2018 11:14:53 -0700 Subject: [PATCH] WIP dont update dygraph unless there are changes --- ui/src/shared/components/Dygraph.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/src/shared/components/Dygraph.js b/ui/src/shared/components/Dygraph.js index 311563ed0..b796d93a3 100644 --- a/ui/src/shared/components/Dygraph.js +++ b/ui/src/shared/components/Dygraph.js @@ -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() {