title: Update parent state from child component and re-render this child when parent state is update
body: <p>I'm learning React and I have trying to find resolution to my problem whole day without success. Then decided to make my first question here.</p>
  <p>I have child component including React-Datepicker component and separate &quot;Next day&quot; and &quot;Previous day&quot; buttons to change the selected date.</p>
  <p>SelectedDate is stored in parent component's state.</p>
  <p>I'm trying to update the parent component's state from child and then when state is updated the child component should re-render as this state is passed as props to this same child.</p>
  <p>I have managed to change the parent state from child, but child component is not re-rendering and therefore the Datepicker date is not updated.</p>
  <p>How should I solve this issue?</p>
  <p>Below is my code without import lines.</p>
  <pre><code>// App.js
  
  function App() {
    const [selectedDate, setSelectedDate] = useState(new Date())
  
    const incrementDate = () =&gt; {
      let next = selectedDate
      next.setDate(next.getDate() + 1)
  
      setSelectedDate(next)
    }
  
    const decrementDate = () =&gt; {
      let previous = selectedDate
      previous.setDate(previous.getDate() - 1)
  
      setSelectedDate(previous)
    }
  
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;Child 
          selectedDate={selectedDate}
          setSelectedDate={setSelectedDate}
          decrementDate={decrementDate}
          incrementDate={incrementDate} /&gt;
      &lt;/div&gt;
    )
  }
  
  // Child.js
  
  const Child = ({ selectedDate, setSelectedDate, decrementDate, incrementDate }) =&gt; {
    return (
      &lt;div className='datepicker-wrapper'&gt;
        &lt;ArrowLeft className='date-arrow' onClick={decrementDate} /&gt;
          &lt;DatePicker
            selected={selectedDate}
            onChange={(date) =&gt; setSelectedDate(date)}
          /&gt;
        &lt;ArrowRight className='date-arrow' onClick={incrementDate} /&gt;
      &lt;/div&gt;
    )
  }
  </code></pre>
  <p><strong>SOLUTION:</strong></p>
  <p>Changed in the increment and decrement functions:</p>
  <pre><code>let next = new Date(selectedDate.valueOf())
  </code></pre>
  <pre><code>let previous = new Date(selectedDate.valueOf())
  </code></pre>