Skip to content

Commit

Permalink
Merge pull request #151 from brigade/unsettimeout
Browse files Browse the repository at this point in the history
Clear timeout when unmounting
  • Loading branch information
lencioni authored Jan 17, 2017
2 parents 0cdb374 + 08c48b3 commit 1623971
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/waypoint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class Waypoint extends React.Component {
// this._ref may occasionally not be set at this time. To help ensure that
// this works smoothly, we want to delay the initial execution until the
// next tick.
setTimeout(() => {
this.initialTimeout = setTimeout(() => {
this._handleScroll(null);
}, 0);
}
Expand All @@ -174,6 +174,8 @@ export default class Waypoint extends React.Component {

removeEventListener(this.scrollEventListenerHandle);
removeEventListener(this.resizeEventListenerHandle);

clearTimeout(this.initialTimeout);
}

/**
Expand Down

0 comments on commit 1623971

Please sign in to comment.