Ever since Hooks were introduced, I have used them instead of classes. For me, I like the way useState initializes and updates the state. This is a personal preference, but I like using functional components more than classes. This does not mean I have a problem with class-based components or hate them.
I do use classes occasionally. Especially when something needs to be done after a component has been unmounted or when the component is updated. I still can't get around to using useEffect well. I find componentWillUnmount and componentDidUpdate easier to use.
As for which one is better, I think both get the job done when it truly matters. It all depends on whether a library needs classes or the developer prefers one over the other.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ever since Hooks were introduced, I have used them instead of classes. For me, I like the way
useState
initializes and updates the state. This is a personal preference, but I like using functional components more than classes. This does not mean I have a problem with class-based components or hate them.I do use classes occasionally. Especially when something needs to be done after a component has been unmounted or when the component is updated. I still can't get around to using
useEffect
well. I findcomponentWillUnmount
andcomponentDidUpdate
easier to use.As for which one is better, I think both get the job done when it truly matters. It all depends on whether a library needs classes or the developer prefers one over the other.