How to set the min and max date in React Native Date Picker

In this React Native source code example, the source code below illustrate how to set the min and max date in React Native Date Picker.

You can copy and adopt this source code example to your React Native project without reinventing the wheel.

import React, { Component } from 'react';
import { View, StyleSheet,DatePickerAndroid,Text} from 'react-native'

export default class App extends Component {
  async  selectDate(){
    try {
  const {action, year, month, day} = await{
    date: new Date(2020, 0, 10),
    minDate:new Date(2020,0,2),
    maxDate:new Date(2020,0, 16)
  if (action !== DatePickerAndroid.dismissedAction) {

      } catch ({code, message}) {
        console.warn('Cannot open date picker', message);
   render() {
      return (
         <View style={styles.container}>
             style={{padding: 10,backgroundColor: 'rgb(94, 200, 100)'}}
             onPress={()=>this.selectDate()}>select date</Text>

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#ddd'

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.


Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.