Skip to content

Commit

Permalink
Set currentDate to be the smaller value date from the passed props.
Browse files Browse the repository at this point in the history
  • Loading branch information
Solera committed Dec 4, 2023
1 parent 56cc719 commit e43622d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/DateTimePickerModal.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ export class DateTimePickerModal extends React.PureComponent {

static getDerivedStateFromProps(props, state) {
if (props.isVisible && !state.isPickerVisible) {
return { currentDate: props.date, isPickerVisible: true };
if (props.date < props.minimumDate) {
console.warn(
"The date property shouldn't be prior to be the minimum date"
);
}
const smallerDateValue =
props.date >= props.minimumDate ? props.date : props.minimumDate;
return { currentDate: smallerDateValue, isPickerVisible: true };
}
return null;
}
Expand Down

0 comments on commit e43622d

Please sign in to comment.