Skip to content

Commit

Permalink
[useScrollTrigger] Add passive flag to scroll trigger event listener #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dsalazar1685 committed Aug 8, 2022
1 parent 764a6a8 commit a804ca8
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -31,9 +31,9 @@ export default function useScrollTrigger(options = {}) {
};

handleScroll(); // Re-evaluate trigger when dependencies change
target.addEventListener('scroll', handleScroll);
target.addEventListener('scroll', handleScroll, { passive: true });
return () => {
target.removeEventListener('scroll', handleScroll);
target.removeEventListener('scroll', handleScroll, { passive: true });
};
// See Option 3. https://github.com/facebook/react/issues/14476#issuecomment-471199055
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit a804ca8

Please sign in to comment.