-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class components can be replaced with functional components #15
Comments
Is there a reason why we should do this? |
Functional components are easier to read, debug, test and generally provide a performance boost as compared to class based components (. In my opinion class components in some situations introduce unwanted complexities, and when code base scales it tends to become difficult to follow the code and for a new comer it can be pretty cumbersome to get started with the project. So that's some of the reasons I believe class components should be replaced with functional components where ever possible. |
@Guttz ^^ |
Classes provide much more structure and organisation when compared to functions. This is generally accepted. Functional designs enable faster prototyping, but that does not necessarily mean they are better. Anything you can do with a function, you can do with a class, but the opposite is not true. If you really think there is a piece of code where a functional approach would be better, please give examples/context. Creating an issue with a generic statement without providing any context/examples seems unhelpful. :/ |
This statement might be true for earlier versions of react, But today scenario is bit different. With the help of React Hooks you can do most of the things using functional components as you would have with a class component. A single hook namely |
Those are good points, @AwesomeChap. Ofc this is not a one-sided discussion and there are people who don't agree with hooks conception and would opine differently, but overall they're been accepted. Perhaps the priority might not be the highest one, there might be other things discussed in other issues that would have a bigger impact for now, but this change would also be welcome. |
I want to work on this issue please assign this issue to me |
No description provided.
The text was updated successfully, but these errors were encountered: