The previous version determined the state in the component constructor. This works as long as the value is provided on the first render. React often renders with missing props initially, so this is a way to make sure a proper render is completed when props arrive a moment later.
The previous version determined the state in the component constructor. This works as long as the value is provided on the first render. React often renders with missing props initially, so this is a way to make sure a proper render is completed when props arrive a moment later.