Skip to content

Commit

Permalink
assert app has set the global bridge if it's using RNReactModuleCell's
Browse files Browse the repository at this point in the history
  • Loading branch information
nyura123 committed Feb 11, 2016
1 parent eaf71ed commit 0fd201b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RNTableView/RNTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@interface RNTableView : UIView

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher bridge:(RCTBridge*) bridge NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;

@property (nonatomic, copy) NSMutableArray *sections;
@property (nonatomic, copy) NSArray *additionalItems;
Expand Down
7 changes: 5 additions & 2 deletions RNTableView/RNTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ - (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
}
}

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher bridge:(RCTBridge*)bridge
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{
RCTAssertParam(eventDispatcher);

if ((self = [super initWithFrame:CGRectZero])) {
_bridge = [[RNAppGlobals sharedInstance] appBridge] ?: bridge;
_bridge = [[RNAppGlobals sharedInstance] appBridge];
_eventDispatcher = eventDispatcher;
_cellHeight = 44;
_cells = [NSMutableArray array];
Expand Down Expand Up @@ -322,6 +322,9 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
}

-(UITableViewCell*)setupReactModuleCell:(UITableView *)tableView data:(NSDictionary*)data indexPath:(NSIndexPath *)indexPath {
RCTAssert(_bridge, @"Must set global bridge in AppDelegate, e.g. \n\
#import <RNTableView/RNAppGlobals.h>\n\
[[RNAppGlobals sharedInstance] setAppBridge:rootView.bridge]");
RNReactModuleCell *cell = [tableView dequeueReusableCellWithIdentifier:_reactModuleCellReuseIndentifier];
if (cell == nil) {
cell = [[RNReactModuleCell alloc] initWithStyle:self.tableViewCellStyle reuseIdentifier:_reactModuleCellReuseIndentifier bridge: _bridge data:data indexPath:indexPath reactModule:_reactModuleForCell];
Expand Down
2 changes: 1 addition & 1 deletion RNTableView/RNTableViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @implementation RNTableViewManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [[RNTableView alloc] initWithEventDispatcher:self.bridge.eventDispatcher bridge:self.bridge];
return [[RNTableView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
}

RCT_EXPORT_VIEW_PROPERTY(sections, NSArray)
Expand Down

0 comments on commit 0fd201b

Please sign in to comment.