Skip to content

Commit

Permalink
[fixed] Cancel requested animation frame on unmount.
Browse files Browse the repository at this point in the history
  • Loading branch information
adriantrunzo authored and diasbruno committed Jun 5, 2021
1 parent fc76b0c commit 0847049
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default class ModalPortal extends Component {
this.afterClose();
}
clearTimeout(this.closeTimer);
cancelAnimationFrame(this.openAnimationFrame);
}

setOverlayRef = overlay => {
Expand Down Expand Up @@ -222,7 +223,7 @@ export default class ModalPortal extends Component {
}

this.setState({ isOpen: true }, () => {
requestAnimationFrame(() => {
this.openAnimationFrame = requestAnimationFrame(() => {
this.setState({ afterOpen: true });

if (this.props.isOpen && this.props.onAfterOpen) {
Expand Down

0 comments on commit 0847049

Please sign in to comment.