Concerning the newly proposed https://reactjs.org/docs/hooks-reference.html#useeffect
- What are the advantages and use cases of the Effect hook (useEffect())?
- Why would it be preferable & how does it differ over componentDidMount/componentDidUpdate/componentWillUnmount (performance/readability)?
The documentation states that:
Mutations, subscriptions, timers, logging, and other side effects are not allowed inside the main body of a function component (referred to as React’s render phase).
but I think it was already common knowledge to have these behaviors in lifecycle methods like componentDidUpdate, etc. instead of the render method
There's also the mention that:
The function passed to useEffect will run after the render is committed to the screen.
but isn't that what componentDidMount & componentDidUpdate do anyways?