mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e5a6655e71
Summary: ## Problem When self is nil, this may crash in RCTUIImageViewAnimated.m. ``` _displayLink = [CADisplayLink displayLinkWithTarget:[RCTWeakProxy weakProxyWithTarget:self] selector:selector(displayDidRefresh:)]; ``` ## Fix Replace `RCTWeakProxy` with a concrete class `RCTDisplayWeakRefreshable` that has the displayDidRefresh method, that calls the displayDidRefresh method in its weak target. ### Original Github Issue https://github.com/facebook/react-native/pull/28070#issuecomment-619295254 Changelog: [iOS] [Fixed] - Fix Animated image crash when CADisplayLink target in RCTWeakProxy is nil Reviewed By: shergin Differential Revision: D21419385 fbshipit-source-id: da7c3c38f81ea54f633da7f59359e07680ea2faf
30 lines
839 B
Objective-C
30 lines
839 B
Objective-C
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTDisplayWeakRefreshable.h"
|
|
|
|
@implementation RCTDisplayWeakRefreshable
|
|
|
|
+ (CADisplayLink *)displayLinkWithWeakRefreshable:(id<RCTDisplayRefreshable>)refreshable {
|
|
RCTDisplayWeakRefreshable *target = [[RCTDisplayWeakRefreshable alloc] initWithRefreshable:refreshable];
|
|
return [CADisplayLink displayLinkWithTarget:target selector:@selector(displayDidRefresh:)];
|
|
}
|
|
|
|
- (instancetype)initWithRefreshable:(id<RCTDisplayRefreshable>)refreshable
|
|
{
|
|
if (self = [super init]) {
|
|
_refreshable = refreshable;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)displayDidRefresh:(CADisplayLink *)displayLink {
|
|
[_refreshable displayDidRefresh:displayLink];
|
|
}
|
|
|
|
@end
|