Reputation: 19
I am new in React , I was reading the Readct offical documentation and I saw that I can create states by two ways , classes and hook. My question is which way should I use for my React projects and why .
Thanks to evryone
Upvotes: 2
Views: 1716
Reputation: 1
Use functional components with hooks for managing state in your React projects.
They're easier to read and write, making your code simpler and more maintainable. Hooks also allow you to reuse code more easily and are better for performance.
Plus, they're the modern way of working with React, so you'll be learning and using the most up-to-date practices.
Upvotes: 0
Reputation: 56
Actually, I see the React community really engaged with Hooks. They are more simple and make your code easier to read and less verbose. Besides, with Hooks is really more easy to refactor your code.
I recommend you to pay more attention to Hooks, but It'll be fine if you see how classes work as well (a lot of projects still use classes).
Upvotes: 1
Reputation: 771
There is an awesome StackOverflow here. There is no right or wrong answer to this. I think that hooks carry the day here.
Upvotes: 0