React state life cycle
See the link from offical webiste:
https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/
Update the state from props:
Sometimes we need to update the state from props, as constructor will only be called once regardless of props change from parent.
We can do that in getDerivedStateFromProps() or componentDidUpdate().
The getDerivedStateFromProps() is static and it may not work before rendering.
The componentDidUpdate() may trigger another rendering and even dead loop.