Skip to content

Commit d9c6585

Browse files
fromcelticparkfacebook-github-bot
authored andcommitted
Fix a crash when keyboard is visible and bridge reload happens
Reviewed By: sahrens Differential Revision: D6573855 fbshipit-source-id: 8768dca7d36782e82fb457f6ff4b09791e669d00
1 parent 5f8d8e9 commit d9c6585

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

React/Modules/RCTEventEmitter.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ + (void)initialize
3737

3838
- (void)sendEventWithName:(NSString *)eventName body:(id)body
3939
{
40-
RCTAssert(_bridge != nil, @"bridge is not set. This is probably because you've "
40+
RCTAssert(_bridge != nil, @"Error when sending event: %@ with body: %@. "
41+
"Bridge is not set. This is probably because you've "
4142
"explicitly synthesized the bridge in %@, even though it's inherited "
42-
"from RCTEventEmitter.", [self class]);
43+
"from RCTEventEmitter.", eventName, body, [self class]);
4344

4445
if (RCT_DEBUG && ![[self supportedEvents] containsObject:eventName]) {
4546
RCTLogError(@"`%@` is not a supported event type for %@. Supported events are: `%@`",

React/Modules/RCTKeyboardObserver.m

+6
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ - (void)stopObserving
5454
[[NSNotificationCenter defaultCenter] removeObserver:self];
5555
}
5656

57+
// Bridge might be already invalidated by the time the keyboard is about to be dismissed.
58+
// This might happen, for example, when reload from the packager is performed.
59+
// Thus we need to check against nil here.
5760
#define IMPLEMENT_KEYBOARD_HANDLER(EVENT) \
5861
- (void)EVENT:(NSNotification *)notification \
5962
{ \
63+
if (!self.bridge) { \
64+
return; \
65+
} \
6066
[self sendEventWithName:@#EVENT \
6167
body:RCTParseKeyboardNotification(notification)]; \
6268
}

0 commit comments

Comments
 (0)