Skip to content

Commit

Permalink
RN: Upgrade AccessibilityInfo.removeEventListener Call Sites
Browse files Browse the repository at this point in the history
Summary:
Upgrades all users of `AccessibilityInfo.removeEventListener` to instead use the return value of `AccessibilityInfo.addEventListener`. This will avoid soft errors from being fired for Facebook products.

Changelog:
[Internal]

Reviewed By: kacieb

Differential Revision: D27595097

fbshipit-source-id: 7133db83c6313ae04e43fc0cc8667f562ba1af2b
  • Loading branch information
yungsters authored and facebook-github-bot committed Apr 9, 2021
1 parent e7275d5 commit ebdf36c
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ class EnabledExample extends React.Component<{}> {
};

componentDidMount() {
AccessibilityInfo.addEventListener(
this._subscription = AccessibilityInfo.addEventListener(
this.props.eventListener,
this._handleToggled,
);
Expand All @@ -853,10 +853,7 @@ class EnabledExample extends React.Component<{}> {
}

componentWillUnmount() {
AccessibilityInfo.removeEventListener(
this.props.eventListener,
this._handleToggled,
);
this._subscription?.remove();
}

_handleToggled = isEnabled => {
Expand Down

0 comments on commit ebdf36c

Please sign in to comment.