mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
(AppState) fix removeEventListener adding another listener when type is blur or focus (#33491)
Summary: I noticed the `AppState.removeEventListener` was in fact calling `addListener` instead of `removeListener` when type is blur or focus. I know this method is deprecated but it can't hurt to fix it. ## Changelog [General] [Fixed] - AppState.removeEventListener correctly removes listener for blur and focus events Pull Request resolved: https://github.com/facebook/react-native/pull/33491 Test Plan: I've thought about adding a unit test, but it isn't that easy since AppState is mocked and the method is deprecated so I don't think it is worth investing too much for it. Reviewed By: cortinico Differential Revision: D35139808 Pulled By: GijsWeterings fbshipit-source-id: 9d8ba157db3a62ea53759e1246f483182faf12f1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8237ff2ef3
commit
9aab25ec53
@@ -154,7 +154,7 @@ class AppState {
|
||||
case 'focus':
|
||||
// $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
|
||||
// $FlowIssue[incompatible-call]
|
||||
emitter.addListener('appStateFocusChange', listener);
|
||||
emitter.removeListener('appStateFocusChange', listener);
|
||||
return;
|
||||
}
|
||||
throw new Error('Trying to unsubscribe from unknown event: ' + type);
|
||||
|
||||
Reference in New Issue
Block a user