Skip to content

Commit

Permalink
Clear timeouts on unmount, fixes mzabriskie#10
Browse files Browse the repository at this point in the history
  • Loading branch information
niftynei committed Apr 4, 2017
1 parent 2bb1cce commit 926bd55
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/components/FlipCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default React.createClass({
this._showBothSides();

// Wait for display above to take effect
setTimeout(() => {
this._flipTimeout = setTimeout(() => {
this.setState({
isFlipped: newProps.flipped
});
Expand Down Expand Up @@ -100,7 +100,12 @@ export default React.createClass({
}

// Hide whichever side of the card is down
setTimeout(this._hideFlippedSide, 600);
this._hideSideTimeout = setTimeout(this._hideFlippedSide, 600);
},

componentWillUnmount() {
clearTimeout(this._hideSideTimeout);
clearTimeout(this._flipTimeout);
},

handleFocus() {
Expand Down

0 comments on commit 926bd55

Please sign in to comment.