Skip to content

Fix AccessibilityInfo.addEventListener("reduceMotionChanged", listener) #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

javascripter
Copy link
Contributor

@javascripter javascripter commented Nov 26, 2020

AccessibilityInfo.addEventListener('reduceMotionChanged') internally uses MediaQueryList returned by window.matchMedia.
https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList
addEventListener prop is only available if MediaQueryList inherits EventTarget, which means for Safari we need to fallback to addListener to prevent crash.

I have received quite a few reports from Sentry indicating this code caused issues on iOS users. React Native Paper and other libraries already rely on this functionality on the web.

  async componentDidMount() {
    AccessibilityInfo.addEventListener(
      'reduceMotionChanged',
      this.updateReduceMotionSettingsInfo
    );
}

@javascripter javascripter force-pushed the accessibility_info_crash_safari_13_or_below branch from e61f3de to 96c90c5 Compare November 26, 2020 06:54
…tener, which does not exist on Safari 13 or below
@javascripter javascripter force-pushed the accessibility_info_crash_safari_13_or_below branch from 96c90c5 to 19f254b Compare November 27, 2020 06:23
@necolas necolas closed this in 1b2bb16 Dec 3, 2020
rnike pushed a commit to VeryBuy/react-native-web that referenced this pull request Sep 13, 2022
'addEventListener' is not supported by Safari <= 13, needs to fallback to 'addListener'

Close necolas#1823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant