Skip to content

Commit

Permalink
fix: support MatchMedia in Safari <= 13 (#154)
Browse files Browse the repository at this point in the history
fix #152
  • Loading branch information
kostia1st authored Jul 17, 2023
1 parent 3a84a2a commit 6bb5507
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/react-collapsed/src/utils/usePrefersReducedMotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export function usePrefersReducedMotion() {
setPrefersReducedMotion(event.matches)
}

mediaQueryList.addEventListener('change', listener)
// Fallback to addListener/removeListener for older browsers, #152
(mediaQueryList.addEventListener ?? mediaQueryList.addListener)('change', listener)
return () => {
mediaQueryList.removeEventListener('change', listener)
(mediaQueryList.removeEventListener ?? mediaQueryList.removeListener)('change', listener)
}
}, [])
return prefersReducedMotion
Expand Down

0 comments on commit 6bb5507

Please sign in to comment.