Skip to content

Commit 9aab25e

Browse files
AntoineDoubovetzkyfacebook-github-bot
AntoineDoubovetzky
authored andcommitted
(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: #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
1 parent 8237ff2 commit 9aab25e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Libraries/AppState/AppState.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class AppState {
154154
case 'focus':
155155
// $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
156156
// $FlowIssue[incompatible-call]
157-
emitter.addListener('appStateFocusChange', listener);
157+
emitter.removeListener('appStateFocusChange', listener);
158158
return;
159159
}
160160
throw new Error('Trying to unsubscribe from unknown event: ' + type);

0 commit comments

Comments
 (0)