Before react hooks, we called functional components to stateless components. At that time it was really faster than class components but what about now?
Since we have react hooks, stateless components are no longer precise. Does the functional components are faster than class components which runs same functions?
e.g. In functional components,
state
variables by using useState
hook.useEffect
can represent componentDidMount
, componentWillReceiveProps
or some other lifecycle methods in Class component.We have many other hook functions but which hooks will make my class components faster or lightweight?
Using React hooks will definitely reduce the amount of code you have to write in comparison to class based components.They are much easier to read and debug. In sense of Performance , in class components :
Cleaning up and applying the effect after every render is task heavy, and we might right run into issues or bugs.
so overall Hooks is a better option. source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With