5 ms·
They could've easily added useOnMount, useOnRender, etc It doesn't matter that they are sugar. Just like useState is built on useReducer, it would be massively
by Griffinsauce 4y ago
They could've easily added useOnMount, useOnRender, etc
It doesn't matter that they are sugar. Just like useState is built on useReducer, it would be massively helpful to simplify and clarify what's going on.
- nightski 4y agoSure but these functions would be trivial to define in one's own code base if they so desired.
- madeofpalk 4y agoThey very purposefully didn't add useOnMount because of the subtle bugs developers introduce when they do things only on mount. People would react to the initial props in componentDidMount, but never respond to their change. Hooks, and useEffect, was supposed to be designed in a way to eliminate that class of bugs.