From ce8257c57b0140e2e8a87ac4d99c492aced19d98 Mon Sep 17 00:00:00 2001 From: Solera Date: Sun, 3 Dec 2023 18:56:58 -0600 Subject: [PATCH] Set currentDate to be the smaller value date from the passed props. --- src/DateTimePickerModal.ios.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DateTimePickerModal.ios.js b/src/DateTimePickerModal.ios.js index 128f559..6c58592 100644 --- a/src/DateTimePickerModal.ios.js +++ b/src/DateTimePickerModal.ios.js @@ -72,7 +72,14 @@ export class DateTimePickerModal extends React.PureComponent { static getDerivedStateFromProps(props, state) { if (props.isVisible && !state.isPickerVisible) { - return { currentDate: props.minimumDate ?? new 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; }