Skip to content

Commit f971977

Browse files
committed
Fix incorrect props usage
1 parent bec39a5 commit f971977

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Diff for: src/plotlyjs-react.jsx

+12-7
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ export default function createPlotlyComponent (Plotly) {
7373
this.p = this.p.then(() => {
7474
return (hasReactAPIMethod ? Plotly.react : Plotly.newPlot)(this.el, {
7575
data: nextProps.data,
76-
layout: this.applySize(this.props.layout),
77-
config: this.props.config,
78-
frames: this.props.frames,
79-
}).then(this.syncEventHandlers);
76+
layout: this.applySize(nextProps.layout),
77+
config: nextProps.config,
78+
frames: nextProps.frames,
79+
}).then(() => {
80+
this.syncEventHandlers(nextProps)
81+
});
8082
});
8183
}
8284

@@ -112,14 +114,17 @@ export default function createPlotlyComponent (Plotly) {
112114
}
113115

114116
// Attach and remove event handlers as they're added or removed from props:
115-
syncEventHandlers() {
117+
syncEventHandlers(props) {
118+
// Allow use of nextProps if passed explicitly:
119+
props = props || this.props;
120+
116121
for (let i = 0; i < eventNames.length; i++) {
117122
const eventName = eventNames[i];
118-
const prop = this.props["on" + eventName];
123+
const prop = props["on" + eventName];
119124
const hasHandler = !!this.handlers[eventName];
120125

121126
if (prop && !hasHandler) {
122-
let handler = (this.handlers[eventName] = this.props[
127+
let handler = (this.handlers[eventName] = props[
123128
"on" + eventName
124129
]);
125130
this.el.on("plotly_" + eventName.toLowerCase(), handler);

0 commit comments

Comments
 (0)