react-native-date-picker
react-native-date-picker copied to clipboard
[ANDROID] If the minimumDate and maximumDate are set on 'date' mode, by openening the datepicker it shows the minimumDate, not the maximumDate
If I set the minimumDate and maximumDate on Android, when I open the Datepicker, it will show me the dates starting from the minimum date (instead of showing me the maximum date like it happens on iOS). So for example, I set the minimumDate to be '1924-03-06' and the maximumDate is '2007-03-06'. When I open the datepicker on Android I see this (6st March 1924 is the minimum date, not the selected one). On IOS it works perfect
ANDROID
IOS
The expected behaviour would be to see when I open the datepicker on 'date' mode the maximum date, even if the minimumDate is set
<DatePicker
modal
mode="date"
locale={i18next.language}
open={datePickerOpen}
date={
dateOfBirth !== ''
? DateTime.fromISO(dateOfBirth).setLocale(i18next.language).toJSDate()
: DateTime.now().setZone('utc').setLocale(i18next.language).toJSDate()
}
onConfirm={onSelectDateOfBirth}
onCancel={toggleDatePicker}
maximumDate={minDate}
minimumDate={maxDate}
/>
- OS: Android
- React Native version: "0.71.13"
- react-native-date-picker version: 4.3.3
Same issuse :(
Is there any workaround for this?
Is there any workaround for this?
You need to adjust either the start date or the selected date to fall within the selectable range of values.
You have to set the date property value the same as the maximumDate property value
Same issue, any update on solution, android specific issue.
Same issue. Is there update about this?
@danhidsan please refer to @Ammarlio comment.
Ensure that the date
prop is passed in the same format as the maximumDate
prop.
Example:
const [date, setDate] = useState(new Date(new Date().setFullYear(new Date().getFullYear() - 10)));
const [open, setOpen] = useState(false);
<DatePicker
modal
open={open}
date={date}
mode={'date'}
maximumDate={new Date(new Date().setFullYear(new Date().getFullYear() - 10))}
onConfirm={newDate => { setOpen(false); setDate(newDate) }}
onCancel={() => { setOpen(false); }}
/>