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

fix: add `useReducedMotion` compatibility for Safari 13 and older #2300

Open BenHodgsonR2R opened 3 days ago

BenHodgsonR2R commented 3 days ago

Why

Currently, calling useReducedMotion on a Safari browser older than v14 causes an error, crashing the app. This pull request adds compatibility checks, so that useReducedMotion can be called on older devices without producing an error.

Resolves https://github.com/pmndrs/react-spring/issues/2299

What

Adds truthy checks to MediaQueryList.addEventListener before attempting to call the function. This function is undefined on older browsers.

Checklist

changeset-bot[bot] commented 3 days ago

🦋 Changeset detected

Latest commit: ab89f433a3da46f0aa393a4e7103804fdb15a94c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages | Name | Type | | ---------------------- | ----- | | @react-spring/shared | Patch | | @react-spring/animated | Patch | | @react-spring/core | Patch | | @react-spring/parallax | Patch | | @react-spring/rafz | Patch | | @react-spring/types | Patch | | @react-spring/konva | Patch | | @react-spring/native | Patch | | @react-spring/three | Patch | | @react-spring/web | Patch | | @react-spring/zdog | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 3 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
react-spring ✅ Ready (Inspect) Visit Preview Jul 1, 2024 11:16am
joshuaellis commented 3 days ago

Can you please add a changeset to the PR? 😊 otherwise looks great to me, thanks for the fix!

BenHodgsonR2R commented 3 days ago

@joshuaellis Thank you for taking a look at this so quickly! Just added the changeset