Skip to main content

DatePickerOverlay

Content

Do not use this component directly!

Use showDatePicker to present this component because it's linked to navigation.

Represents a date picker provided by @react-native-community/datetimepicker as modal on iOS and as overlay on Android.

Params

NameTypeRequiredDefault valueDescription
valueDateTrue-Current selected date value
minDateDateFalseUndefinedMinimum border of available dates for selection
maxDateDateFalseUndefinedMaximum border of available dates for selection
onDateChange(date: Date) => void FalseUndefinedCallback with selected date

Usage example

const [selectedDate, setSelectedDate] = useState<Date>(new Date());

const onPress = useCallback(() => {
return showDatePicker({
value: selectedDate,
onDateChange: setSelectedDate,
});
}, [selectedDate, setSelectedDate]);

return (
<ScrollView style={CommonStyles.flexPlatformBackground} contentContainerStyle={CommonStyles.flexColumnCenterStretch}>
<PrimaryButton type={ButtonType.solid} label={"Select date"} onPress={onPress} />
<DescriptionText>{dateFromFormat(selectedDate, DateFormat.yearDateTime)}</DescriptionText>
</ScrollView>
);