Skip to content

Commit

Permalink
Add null check in ScrollCaptor.stopListening
Browse files Browse the repository at this point in the history
  • Loading branch information
Rall3n committed Dec 10, 2020
1 parent 18a6bb2 commit 0aba924
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/react-select/src/internal/ScrollCaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class ScrollCaptor extends Component<CaptorProps> {
}
}
stopListening(el: HTMLElement) {
// bail early if no element is available to detach from
if (!el) return;

// all the if statements are to appease Flow 😢
if (typeof el.removeEventListener === 'function') {
el.removeEventListener('wheel', this.onWheel, false);
Expand Down

0 comments on commit 0aba924

Please sign in to comment.