Skip to content

Commit

Permalink
Properly recycle RCTPullToRefreshViewcomponentView (#44047)
Browse files Browse the repository at this point in the history
Summary:

This change properly recycles the RCTPullToRefreshViewComponentView so that it fixes some misbehaviors of the UIRefreshControl in OSS.

This should fix #37308 and #36173

## Changelog:
[iOS][Fixed] - Properly recycle the RCTPullToRefreshViewComponentView

Differential Revision: D56018924
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Apr 11, 2024
1 parent affadb6 commit 4b625f4
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,34 @@ - (instancetype)initWithFrame:(CGRect)frame
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
{
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);
Expand Down Expand Up @@ -113,6 +124,7 @@ - (void)_updateTitle

- (void)didMoveToWindow
{
[super didMoveToWindow];
if (self.window) {
[self _attach];
} else {
Expand Down

0 comments on commit 4b625f4

Please sign in to comment.