Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekszeliga committed Nov 9, 2017
1 parent 1e2a924 commit bf8b4d3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions React/Views/RCTDatePicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ - (instancetype)initWithFrame:(CGRect)frame
- (void)didChange
{
if (_onChange) {
_onChange(@{ @"timestamp": @(self.date.timeIntervalSince1970 * 1000.0) });
}
// Use a weak reference to `self` to avoid a retain cycle.
__weak __typeof__(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
_onChange(@{ @"timestamp": @(weakSelf.date.timeIntervalSince1970 * 1000.0)});
});
}
}

@end

0 comments on commit bf8b4d3

Please sign in to comment.