Skip to content

Commit ab21d73

Browse files
Peter Arganyfacebook-github-bot
authored andcommitted
Fix crash in RCTEventEmitter
Summary: According to the crash, RCTEventEmitter is being asked to emit events before RN is set up {emoji:1f928}. Neither the bridge, nor bridgeless mode is ready to send events. In this scenario, drop the events on the floor instead of crashing. Changelog: [Internal] Reviewed By: naftaly Differential Revision: D24634701 fbshipit-source-id: 933e5dfd15e5ee7c2215489305c71de46e78a9e5
1 parent e37708d commit ab21d73

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

React/CoreModules/RCTEventDispatcher.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ - (void)sendAppEventWithName:(NSString *)name body:(id)body
6565
method:@"emit"
6666
args:body ? @[ name, body ] : @[ name ]
6767
completion:NULL];
68-
} else {
68+
} else if (_invokeJS) {
6969
_invokeJS(@"RCTNativeAppEventEmitter", @"emit", body ? @[ name, body ] : @[ name ]);
7070
}
7171
}
@@ -77,7 +77,7 @@ - (void)sendDeviceEventWithName:(NSString *)name body:(id)body
7777
method:@"emit"
7878
args:body ? @[ name, body ] : @[ name ]
7979
completion:NULL];
80-
} else {
80+
} else if (_invokeJS) {
8181
_invokeJS(@"RCTDeviceEventEmitter", @"emit", body ? @[ name, body ] : @[ name ]);
8282
}
8383
}
@@ -198,7 +198,7 @@ - (void)dispatchEvent:(id<RCTEvent>)event
198198
{
199199
if (_bridge) {
200200
[_bridge enqueueJSCall:[[event class] moduleDotMethod] args:[event arguments]];
201-
} else {
201+
} else if (_invokeJSWithModuleDotMethod) {
202202
_invokeJSWithModuleDotMethod([[event class] moduleDotMethod], [event arguments]);
203203
}
204204
}

0 commit comments

Comments
 (0)