From f9ea37d116e17c0cb4d4a21c405c9d749783b93a Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Tue, 6 Mar 2018 21:56:38 -0500 Subject: [PATCH] shallow equality check before Plotly.react --- src/factory.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/factory.js b/src/factory.js index ae27950..176c81a 100644 --- a/src/factory.js +++ b/src/factory.js @@ -66,13 +66,6 @@ export default function plotComponentFactory(Plotly) { this.handleUpdateWithProps = this.handleUpdateWithProps.bind(this); } - shouldComponentUpdate(nextProps) { - return ( - nextProps.revision === void 0 || - nextProps.revision !== this.props.revision - ); - } - componentDidMount() { this.p = this.p .then(() => { @@ -96,6 +89,17 @@ export default function plotComponentFactory(Plotly) { } componentWillUpdate(nextProps) { + if ( + (nextProps.revision !== void 0 && + nextProps.revision === this.props.revision) || + (nextProps.layout === this.props.layout && + nextProps.data === this.props.data && + nextProps.config === this.props.config && + nextProps.frames === this.props.frames) + ) { + return; + } + this.p = this.p .then(() => { if (hasReactAPIMethod) {