Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d84748

Browse files
author
Juraj Moško
committed
fix(refs): fixed issue with referencing element of unmounted component
#199
1 parent 0ada702 commit 3d84748

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

‎src/factory.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,32 @@ export default function plotComponentFactory(Plotly) {
6767
updatePlotly(shouldInvokeResizeHandler, figureCallbackFunction, shouldAttachUpdateEvents) {
6868
this.p = this.p
6969
.then(() => {
70+
if (this.unmounting) {
71+
return;
72+
}
7073
if (!this.el) {
71-
let error;
72-
if (this.unmounting) {
73-
error = new Error('Component is unmounting');
74-
error.reason = 'unmounting';
75-
} else {
76-
error = new Error('Missing element reference');
77-
}
78-
throw error;
74+
throw new Error('Missing element reference');
7975
}
76+
// eslint-disable-next-line consistent-return
8077
return Plotly.react(this.el, {
8178
data: this.props.data,
8279
layout: this.props.layout,
8380
config: this.props.config,
8481
frames: this.props.frames,
8582
});
8683
})
87-
.then(() => this.syncWindowResize(shouldInvokeResizeHandler))
88-
.then(this.syncEventHandlers)
89-
.then(() => this.figureCallback(figureCallbackFunction))
90-
.then(shouldAttachUpdateEvents ? this.attachUpdateEvents : () => {})
91-
.catch(err => {
92-
if (err.reason === 'unmounting') {
84+
.then(() => {
85+
if (this.unmounting) {
9386
return;
9487
}
95-
console.error('Error while plotting:', err); // eslint-disable-line no-console
88+
this.syncWindowResize(shouldInvokeResizeHandler);
89+
this.syncEventHandlers();
90+
this.figureCallback(figureCallbackFunction);
91+
if (shouldAttachUpdateEvents) {
92+
this.attachUpdateEvents();
93+
}
94+
})
95+
.catch(err => {
9696
if (this.props.onError) {
9797
this.props.onError(err);
9898
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /