Skip to content

Commit

Permalink
Partially implemented view recycling for Slider with note to improve
Browse files Browse the repository at this point in the history
Summary: Recycling and dealloc were not implemented at all before for Slider, so I've taken a first stab at it. It's a little more complex than I initially thought, due to things I don't 100% understand about UISlider as well as Fabric, so I've left a TODO note to fix this at some point. We should be aware that view recycling doesn't appear to be working the way I would expect currently though.

Reviewed By: shergin

Differential Revision: D13965475

fbshipit-source-id: fd18a219cead770b63b514fdc868e23214e735b7
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Feb 6, 2019
1 parent 550a14c commit 3cca9e7
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,44 @@ - (instancetype)initWithFrame:(CGRect)frame
return self;
}

// Recycling still doesn't work 100% properly
// TODO: T40099998 implement recycling properly for Fabric Slider component
- (void)prepareForRecycle
{
[super prepareForRecycle];

self.trackImageCoordinator = nullptr;
self.minimumTrackImageCoordinator = nullptr;
self.maximumTrackImageCoordinator = nullptr;
self.thumbImageCoordinator = nullptr;

_sliderLocalData.reset();

// Tint colors will be taken care of when props are set again - we just
// need to make sure that image properties are reset here
[_sliderView setMinimumTrackImage:nil forState:UIControlStateNormal];
[_sliderView setMaximumTrackImage:nil forState:UIControlStateNormal];
[_sliderView setThumbImage:nil forState:UIControlStateNormal];

_trackImage = nil;
_minimumTrackImage = nil;
_maximumTrackImage = nil;
_thumbImage = nil;
}

-(void)dealloc
{
self.trackImageCoordinator = nullptr;
self.minimumTrackImageCoordinator = nullptr;
self.maximumTrackImageCoordinator = nullptr;
self.thumbImageCoordinator = nullptr;

_trackImageResponseObserverProxy.reset();
_minimumTrackImageResponseObserverProxy.reset();
_maximumTrackImageResponseObserverProxy.reset();
_thumbImageResponseObserverProxy.reset();
}

#pragma mark - RCTComponentViewProtocol

+ (ComponentHandle)componentHandle
Expand Down

0 comments on commit 3cca9e7

Please sign in to comment.