title: Why getDerivedStateFromProps is called after setState?
body: <p>React introduced new static method <code>getDerivedStateFromProps(props, state)</code> which is called before every render method, but why? Calling it after prop change makes sense to me but after <code>setState</code> it doesn't, maybe I am missing something.</p>
  
  <p>I was creating a <code>datePicker</code> Component according to my company requirement, in the component date is controlled from the prop. I have the following state in the component.</p>
  
  <pre><code>selectedDate: number;
  selectedMonth: number;
  selectedYear: number;
  currentMonth: number;
  currentYear: number;
  view: string;
  </code></pre>
  
  <p>selected represents selected date which is derived from date prop and <code>currentMonth</code> and <code>currentYear</code> represents month and year in the current calendar view.</p>
  
  <p>If <code>date</code> from prop changes <code>selected*</code>, <code>currentMonth</code> and <code>currentYear</code> should be changed accordingly. For that, I am using <code>getDerivedStateFromProps</code> but let say user clicks on Month name which will switch calendar view to month (instead of dates name of the month will be shown), the function updates the <code>currentMonth</code> for this using setState, but date the prop is same as before (containing previous month) which should, but <code>getDerivedStateFromProps</code> is called and currentMonth is again as same as before instead of changing.</p>
  
  <p>Right I creating an extra variable in <code>state</code> to track if <code>getDerivedStateFromProps</code> is called due to <code>setState</code> but I don't think that's the right way. </p>
  
  <p>Either I am doing something wrong or missing something or <code>getDerivedStateFromProps</code> should not be called after <code>setState</code>. Probably I am doing something wrong.</p>