Skip to content

Commit a6945e8

Browse files
authored
Only unbind events passed from the parent component (#613)
`initEchartsInstance` attached a handler for the `"finish"` event. If `componentDidUpdate` is called between attaching the handler, and firing the handler and the `onEvents` prop changed, this will fire `"offEvents"` which will remove the handler for the `"finish"` event. This means the finish handler never fires, so the chart auto-resize is not attached, and the ready event handler never fires. Instead, only remove the events that are on the previous props, and leave the `"finish"` callback alone.
1 parent 3739822 commit a6945e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/core.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
190190
// loop and off
191191
for (const eventName in events) {
192192
if (isString(eventName)) {
193-
instance.off(eventName);
193+
instance.off(eventName, events[eventName]);
194194
}
195195
}
196196
}

0 commit comments

Comments
 (0)