Why getDerivedStateFromProps is called after setState?
问题 React introduced new static method getDerivedStateFromProps(props, state) which is called before every render method, but why? Calling it after prop change makes sense to me but after setState it doesn't, maybe I am missing something. I was creating a datePicker Component according to my company requirement, in the component date is controlled from the prop. I have the following state in the component. selectedDate: number; selectedMonth: number; selectedYear: number; currentMonth: number;