diff --git a/react-native/RealmReact.mm b/react-native/RealmReact.mm index d1bd84c6..6715a88c 100644 --- a/react-native/RealmReact.mm +++ b/react-native/RealmReact.mm @@ -96,7 +96,10 @@ extern "C" JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executo } - (void)addListenerForEvent:(NSString *)eventName handler:(RealmReactEventHandler)handler { - NSMutableOrderedSet *handlers = _eventHandlers[eventName] ?: (_eventHandlers[eventName] = [[NSMutableOrderedSet alloc] init]); + NSMutableOrderedSet *handlers = _eventHandlers[eventName]; + if (!handlers) { + handlers = _eventHandlers[eventName] = [[NSMutableOrderedSet alloc] init]; + } [handlers addObject:handler]; }