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 971653e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions RNTableView/RNTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import <UIKit/UIKit.h>
@class RCTEventDispatcher;
@class RCTBridge;

@protocol RNTableViewDatasource <NSObject>

Expand All @@ -22,7 +21,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
8 changes: 5 additions & 3 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 @@ -286,7 +286,6 @@ - (void)setSections:(NSArray *)sections
if(selectedIndex == -1)
selectedIndex = [items count];
itemData[@"selected"] = @YES;

found = YES;
}
[items addObject:itemData];
Expand Down Expand Up @@ -322,6 +321,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
1 change: 0 additions & 1 deletion examples/TableViewDemo/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class FirebaseExample extends React.Component {
this.propPrefix = "dinosaur";
}
componentDidMount() {
var dinData = null;
var self = this;
this.ref = new Firebase(this.firebaseLocation);
this.ref.on('value', function(snapshot) {
Expand Down

0 comments on commit 971653e

Please sign in to comment.