mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Properly recycle RCTPullToRefreshViewcomponentView (#44047)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44047 This change properly recycles the RCTPullToRefreshViewComponentView so that it fixes some misbehaviors of the UIRefreshControl in OSS. This should fix https://github.com/facebook/react-native/issues/37308 and https://github.com/facebook/react-native/issues/36173 ## Changelog: [iOS][Fixed] - Properly recycle the RCTPullToRefreshViewComponentView Reviewed By: sammy-SC Differential Revision: D56018924 fbshipit-source-id: 3c71328aa0f6fb2a98a19593f0f06419e04e9cae
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7131f94895
commit
18f0a90358
+17
-5
@@ -37,16 +37,20 @@ using namespace facebook::react;
|
||||
self.hidden = YES;
|
||||
|
||||
_props = PullToRefreshViewShadowNode::defaultSharedProps();
|
||||
|
||||
_refreshControl = [UIRefreshControl new];
|
||||
[_refreshControl addTarget:self
|
||||
action:@selector(handleUIControlEventValueChanged)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
[self _initializeUIRefreshControl];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_initializeUIRefreshControl
|
||||
{
|
||||
_refreshControl = [UIRefreshControl new];
|
||||
[_refreshControl addTarget:self
|
||||
action:@selector(handleUIControlEventValueChanged)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
}
|
||||
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
||||
@@ -54,6 +58,13 @@ using namespace facebook::react;
|
||||
return concreteComponentDescriptorProvider<PullToRefreshViewComponentDescriptor>();
|
||||
}
|
||||
|
||||
- (void)prepareForRecycle
|
||||
{
|
||||
[super prepareForRecycle];
|
||||
_scrollViewComponentView = nil;
|
||||
[self _initializeUIRefreshControl];
|
||||
}
|
||||
|
||||
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
||||
{
|
||||
const auto &oldConcreteProps = static_cast<const PullToRefreshViewProps &>(*_props);
|
||||
@@ -113,6 +124,7 @@ using namespace facebook::react;
|
||||
|
||||
- (void)didMoveToWindow
|
||||
{
|
||||
[super didMoveToWindow];
|
||||
if (self.window) {
|
||||
[self _attach];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user