Skip to content

Commit d076c91

Browse files
tstehrdiasbruno
authored andcommitted
Fix not cancelling delayed portal removal when component is remounted
Fixes #1063
1 parent 4b0574a commit d076c91

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/Modal.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ class Modal extends Component {
131131
componentDidMount() {
132132
if (!canUseDOM) return;
133133

134+
clearTimeout(this.removePortalTimer);
135+
134136
if (!isReact16) {
135137
this.node = createHTMLElement("div");
136138
}
@@ -183,7 +185,7 @@ class Modal extends Component {
183185
this.portal.closeWithTimeout();
184186
}
185187

186-
setTimeout(this.removePortal, closesAt - now);
188+
this.removePortalTimer = setTimeout(this.removePortal, closesAt - now);
187189
} else {
188190
this.removePortal();
189191
}

0 commit comments

Comments
 (0)