pmndrs / react-spring

✌️ A spring physics based React animation library
http://www.react-spring.dev/
MIT License
27.73k stars 1.18k forks source link

[bug]: useReducedMotion: error on Safari < 14 #2299

Open BenHodgsonR2R opened 3 days ago

BenHodgsonR2R commented 3 days ago

Which react-spring target are you using?

What version of react-spring are you using?

9.7.3

What's Wrong?

The useReducedMotion hook calls MediaQueryList.addEventListener(), this causes an error in older Safari browsers- which are yet to have this function available.

To Reproduce

Expected Behaviour

Doesn't throw an error and also honours the (prefers-reduced-motion) media query.

Link to repo

https://codesandbox.io/s/eager-gould-hm3rtj?file=/src/App.tsx