Skip to content

Commit db8f5e6

Browse files
committed
Revert shouldComponentUpdate
1 parent 7ce6527 commit db8f5e6

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/factory.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,6 @@ export default function plotComponentFactory(Plotly) {
6464
this.updatePlotly = this.updatePlotly.bind(this);
6565
}
6666

67-
shouldComponentUpdate(nextProps) {
68-
// frames *always* changes identity so fall back to check length only :(
69-
const numPrevFrames =
70-
this.props.frames && this.props.frames.length ? this.props.frames.length : 0;
71-
const numNextFrames =
72-
nextProps.frames && nextProps.frames.length ? nextProps.frames.length : 0;
73-
74-
const figureChanged = !(
75-
nextProps.layout === this.props.layout &&
76-
nextProps.data === this.props.data &&
77-
nextProps.config === this.props.config &&
78-
numNextFrames === numPrevFrames
79-
);
80-
const revisionDefined = nextProps.revision !== void 0;
81-
const revisionChanged = nextProps.revision !== this.props.revision;
82-
83-
return figureChanged || (revisionDefined && revisionChanged);
84-
}
85-
8667
updatePlotly(
8768
props,
8869
shouldInvokeResizeHandler,
@@ -132,6 +113,25 @@ export default function plotComponentFactory(Plotly) {
132113
componentDidUpdate(nextProps) {
133114
this.unmounting = false;
134115

116+
// frames *always* changes identity so fall back to check length only :(
117+
const numPrevFrames =
118+
this.props.frames && this.props.frames.length ? this.props.frames.length : 0;
119+
const numNextFrames =
120+
nextProps.frames && nextProps.frames.length ? nextProps.frames.length : 0;
121+
122+
const figureChanged = !(
123+
nextProps.layout === this.props.layout &&
124+
nextProps.data === this.props.data &&
125+
nextProps.config === this.props.config &&
126+
numNextFrames === numPrevFrames
127+
);
128+
const revisionDefined = nextProps.revision !== void 0;
129+
const revisionChanged = nextProps.revision !== this.props.revision;
130+
131+
if (!figureChanged && (!revisionDefined || (revisionDefined && !revisionChanged))) {
132+
return;
133+
}
134+
135135
this.updatePlotly(nextProps, false, nextProps.onUpdate, false);
136136
}
137137

0 commit comments

Comments
 (0)