Movatterモバイル変換


[0]ホーム

URL:


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

Commit538eac5

Browse files
authored
Merge pull request#200 from sincersoft/pr/exit_callback_when_unmounting
fix(refs): fixed issue with referencing element of unmounted component
2 parents0ada702 +3d84748 commit538eac5

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-
leterror;
72-
if(this.unmounting){
73-
error=newError('Component is unmounting');
74-
error.reason='unmounting';
75-
}else{
76-
error=newError('Missing element reference');
77-
}
78-
throwerror;
74+
thrownewError('Missing element reference');
7975
}
76+
// eslint-disable-next-line consistent-return
8077
returnPlotly.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)

[8]ページ先頭

©2009-2025 Movatter.jp