Skip to content

Commit 3d27277

Browse files
author
Solera
committed
Set currentDate to be prop.minimumDate if not null or the current date.
Set currentDate to be the smaller value date from the passed props.
1 parent 56cc719 commit 3d27277

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/DateTimePickerModal.ios.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ export class DateTimePickerModal extends React.PureComponent {
7272

7373
static getDerivedStateFromProps(props, state) {
7474
if (props.isVisible && !state.isPickerVisible) {
75-
return { currentDate: props.date, isPickerVisible: true };
75+
if (props.date < props.minimumDate) {
76+
console.warn(
77+
"The date property shouldn't be prior to be the minimum date"
78+
);
79+
}
80+
const smallerDateValue =
81+
props.date >= props.minimumDate ? props.date : props.minimumDate;
82+
return { currentDate: smallerDateValue, isPickerVisible: true };
7683
}
7784
return null;
7885
}

0 commit comments

Comments
 (0)