Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ @implementation RCTDisplayWeakRefreshable

+ (RCTPlatformDisplayLink *)displayLinkWithWeakRefreshable:(id<RCTDisplayRefreshable>)refreshable // [macOS]
{
#if !TARGET_OS_OSX // [macOS]
RCTDisplayWeakRefreshable *target = [[RCTDisplayWeakRefreshable alloc] initWithRefreshable:refreshable];
return [RCTPlatformDisplayLink displayLinkWithTarget:target selector:@selector(displayDidRefresh:)]; // [macOS]
#else // [macOS
// CADisplayLink retains its target, so on iOS the weak proxy above is needed to avoid a retain cycle.
// RCTPlatformDisplayLink only holds its target weakly, so the proxy would have no owner and be
// deallocated immediately, and the refreshable would never be called. Target the refreshable directly.
return [RCTPlatformDisplayLink displayLinkWithTarget:refreshable selector:@selector(displayDidRefresh:)];
#endif // macOS]
}

- (instancetype)initWithRefreshable:(id<RCTDisplayRefreshable>)refreshable
Expand Down
Loading