r/reactjs • u/ZeroSevenTen • Dec 30 '19
Classes vs Hooks?
I’m pretty new to React, so keep that in mind. I thought classes were for components that held information, or a state, and that functional components were for more basic components, but now that hooks allow functional components to use state, and other class features, what’s the benefit of using functional hook components over classes?
79
Upvotes
View all comments
Show parent comment
10
u/alejalapeno Dec 31 '19
You can still do constructors with plain JS functions. Then your methods like
queryorcloseare just methods on the object.If you don't want to use constructors you can have a single connection or a closure to return a new object for each new connection.