Skip to content

Commit

Permalink
Set currentDate to be prop.minimumDate if not null or the current date.
Browse files Browse the repository at this point in the history
Set currentDate to be the smaller value date from the passed props.
  • Loading branch information
Solera committed Dec 4, 2023
1 parent 56cc719 commit 3d27277
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 3d27277

Please sign in to comment.