Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,32 @@ export default function plotComponentFactory(Plotly) {
updatePlotly(shouldInvokeResizeHandler, figureCallbackFunction, shouldAttachUpdateEvents) {
this.p = this.p
.then(() => {
if (this.unmounting) {
return;
}
if (!this.el) {
let error;
if (this.unmounting) {
error = new Error('Component is unmounting');
error.reason = 'unmounting';
} else {
error = new Error('Missing element reference');
}
throw error;
throw new Error('Missing element reference');
}
// eslint-disable-next-line consistent-return
return Plotly.react(this.el, {
data: this.props.data,
layout: this.props.layout,
config: this.props.config,
frames: this.props.frames,
});
})
.then(() => this.syncWindowResize(shouldInvokeResizeHandler))
.then(this.syncEventHandlers)
.then(() => this.figureCallback(figureCallbackFunction))
.then(shouldAttachUpdateEvents ? this.attachUpdateEvents : () => {})
.catch(err => {
if (err.reason === 'unmounting') {
.then(() => {
if (this.unmounting) {
return;
}
console.error('Error while plotting:', err); // eslint-disable-line no-console
this.syncWindowResize(shouldInvokeResizeHandler);
this.syncEventHandlers();
this.figureCallback(figureCallbackFunction);
if (shouldAttachUpdateEvents) {
this.attachUpdateEvents();
}
})
.catch(err => {
if (this.props.onError) {
this.props.onError(err);
}
Expand Down