Skip to content

Commit b51bd41

Browse files
committed
fix(ios): internal picker state persisting with recycling
1 parent 914c8f2 commit b51bd41

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

ios/RNDateTimePicker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99

1010
@interface RNDateTimePicker : UIDatePicker
1111

12+
- (void)reset;
13+
1214
@end

ios/RNDateTimePicker.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,11 @@ - (void)setDate:(NSDate *)date {
7272
}
7373
}
7474

75+
- (void)reset
76+
{
77+
self.minimumDate = nil;
78+
self.maximumDate = nil;
79+
self.date = [NSDate date];
80+
}
81+
7582
@end

ios/fabric/RNDateTimePickerComponentView.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ @interface RNDateTimePickerComponentView () <RCTRNDateTimePickerViewProtocol>
4040
@end
4141

4242
@implementation RNDateTimePickerComponentView {
43-
UIDatePicker *_picker;
43+
RNDateTimePicker *_picker;
4444
// Dummy picker to apply prop changes and calculate/update the size before the actual picker gets updated
45-
UIDatePicker *_dummyPicker;
45+
RNDateTimePicker *_dummyPicker;
4646
RNDateTimePickerShadowNode::ConcreteState::Shared _state;
4747
}
4848

@@ -119,6 +119,8 @@ - (void)prepareForRecycle
119119
{
120120
[super prepareForRecycle];
121121
_state.reset();
122+
[_picker reset];
123+
[_dummyPicker reset];
122124
}
123125

124126
-(void)updateTextColorForPicker:(UIDatePicker *)picker color:(UIColor *)color

0 commit comments

Comments
 (0)