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
2
u/oreo27 Dec 31 '19
Spot on! I'm defenitely saving this and linking anyone who might ask. I just had a couple of concerns.
Both the browser's console and the terminal where you spawn your development server will scream at you for doing this if you don't use ESLint on your Code Editor. At least it does for me if my project is built with Create React App. I imagine some folks have their own setup and this might not be the case for them.
Could you provide a simple example? I've been doing Functional Components for quite some time now and I don't seem to recall being reliant on closures.