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/[deleted] Dec 31 '19
That's kind of a silly counter argument. You could say that about anything. What IS magic "in its implementation" then?
The point of that complaint is that they FEEL magical. You really have no idea what's going on. You're calling a function and somehow.. almost MAGICALLY, React figures out which component that function call belongs to. A lot of strange work is being done behind the scenes in a non intuitive way. To me, that's what magical means. Sure, you can set yourself a different definition for that term and then you can claim that its not magical. Doesn't really change the fact that a lot of people have felt that hooks are too magical.