title: Datepicker displays only the previous date, not the most recently selected date
body: <p>I'm using <code>React</code>, and have components in <code>DatePicker</code>.</p>
  <p>Currently, when I select a date in DatePicker I can only get the previously selected date to print in console, so when I first access the webpage it always tells me the default date of January 1st, 2021 instead of the date I selected.</p>
  <p>How can I make datepicker display the selected date and not the preivously selected one?</p>
  <p>my code:</p>
  <pre><code>import DatePicker from &quot;react-datepicker&quot;;
  
  const [startDate, setStartDate] = useState(new Date());
  const [endDate, setEndDate] = useState(new Date());
  
  const handleChange = date =&gt; {
      const valueOfInput = date;
      console.log(valueOfInput)
    };
  
  &lt;div&gt; 
            From
            &lt;DatePicker selected={startDate} onChange={(v =&gt; setStartDate(v))} dateFormat=&quot;yyyy-MM&quot; showMonthYearPicker showFullMonthYearPicker showTwoColumnMonthYearPicker todayButton=&quot;Today&quot; maxDate={new Date()} placeholderText='Results from:' defaultDate={''}/&gt;
            To
            &lt;DatePicker selected={endDate} onChange={(v =&gt; setEndDate(v))} dateFormat=&quot;yyyy-MM&quot; showMonthYearPicker showFullMonthYearPicker showTwoColumnMonthYearPicker todayButton=&quot;Today&quot; maxDate={new Date()} placeholderText='Results to:' defaultDate={''}/&gt;
        &lt;/div&gt;
  </code></pre>
  <p>Selecting a date such as february 2011, currently yeilds:
  <code>Fri Jan 01 2021 14:49:33 GMT-0500 (Eastern Standard Time)</code></p>
  <p>but when I click on that it should yield:
  <code>Fri Feb 01 2011 14:49:33 GMT-0500 (Eastern Standard Time)</code></p>