If you look in the reaction code for your own views that they implemented:
https://github.com/facebook/react-native/tree/master/React/Views
it looks like the documentation is out of date and instead of using:
[self.bridge.eventDispatcher sendInputEventWithName...
You should do the following:
@property (nonatomic, copy) RCTBubblingEventBlock onTopChange; self.onTopChange(@{ @"region": @{ @"latitude": @(region.center.latitude), @"longitude": @(region.center.longitude), @"latitudeDelta": @(region.span.latitudeDelta), @"longitudeDelta": @(region.span.longitudeDelta), } };
There's also RCTDirectEventBlock
I'm not sure what the difference is between this and RCTBubblingEventBlock
Looking at the lines of RCTComponent.m
160-169, it should automatically configure the target setting:
// Special case for event handlers __weak RCTViewManager *weakManager = _manager; setterBlock = ^(id target, __unused id source, id json) { __weak id<RCTComponent> weakTarget = target; ((void (*)(id, SEL, id))objc_msgSend)(target, setter, [RCTConvert BOOL:json] ? ^(NSDictionary *body) { body = [NSMutableDictionary dictionaryWithDictionary:body]; ((NSMutableDictionary *)body)[@"target"] = weakTarget.reactTag; [weakManager.bridge.eventDispatcher sendInputEventWithName:RCTNormalizeInputEventName(name) body:body]; } : nil); };
Also in the Manager class, make sure you add:
RCT_EXPORT_VIEW_PROPERTY(onTopChange, RCTBubblingEventBlock)
And don't forget to actually hook up the event in your JSX:
<MyComponent onTopChange={this.handleOnTopChange}/>