title: how to enable and disable previous and future date on react-native-community/datetimepicker in React Native
body: <p>I have implemented the date-picker in my app. i used the <code> react-native-community/datetimepicker</code> package for date-picker. But i have to add the custom option/methods ,by using that i can enable and disable the dates and also want to disable the previous dates. I am unable to implement it. <strong>Also the date time is not updating continuously</strong>. So please suggest any solution.</p>
  <p>Code:</p>
  <pre><code>import React, {useState} from 'react';
  import {View, Button, Platform} from 'react-native';
  import DateTimePicker from '@react-native-community/datetimepicker';
  
  export const CustomDatePicker = () =&gt; {
    const [date, setDate] = useState(new Date());
    const [mode, setMode] = useState('date');
    const [show, setShow] = useState(false);
  
    const onChange = (event, selectedDate) =&gt; {
      const currentDate = selectedDate || date;
      setShow(Platform.OS === 'ios');
      setDate(currentDate);
    };
  
    const showMode = (currentMode) =&gt; {
      setShow(true);
      setMode(currentMode);
    };
  
    const showDatepicker = () =&gt; {
      showMode('date');
    };
  
  
    return (
      &lt;View&gt;
        &lt;View&gt;
          &lt;Button onPress={showDatepicker} title=&quot;Show date picker!&quot; /&gt;
        &lt;/View&gt;
      
        {show &amp;&amp; (
          &lt;DateTimePicker
            testID=&quot;dateTimePicker&quot;
            value={date}
            mode={mode}
            is24Hour={true}
            display=&quot;default&quot;
            onChange={onChange}
          /&gt;
        )}
      &lt;/View&gt;
    );
  };
  </code></pre>