Skip to content

Commit 0847049

Browse files
adriantrunzodiasbruno
authored andcommittedJun 5, 2021
[fixed] Cancel requested animation frame on unmount.
1 parent fc76b0c commit 0847049

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/components/ModalPortal.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default class ModalPortal extends Component {
131131
this.afterClose();
132132
}
133133
clearTimeout(this.closeTimer);
134+
cancelAnimationFrame(this.openAnimationFrame);
134135
}
135136

136137
setOverlayRef = overlay => {
@@ -222,7 +223,7 @@ export default class ModalPortal extends Component {
222223
}
223224

224225
this.setState({ isOpen: true }, () => {
225-
requestAnimationFrame(() => {
226+
this.openAnimationFrame = requestAnimationFrame(() => {
226227
this.setState({ afterOpen: true });
227228

228229
if (this.props.isOpen && this.props.onAfterOpen) {

0 commit comments

Comments
 (0)
Please sign in to comment.