Skip to content
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

Open
AwesomeChap opened this issue Oct 27, 2019 · 7 comments
Open

Class components can be replaced with functional components #15

AwesomeChap opened this issue Oct 27, 2019 · 7 comments

Comments

@AwesomeChap
Copy link

No description provided.

@AwesomeChap AwesomeChap changed the title Replace class components with functional components where ever possible Class components can be replaced with functional components Oct 27, 2019
@xadahiya
Copy link
Member

Is there a reason why we should do this?

@AwesomeChap
Copy link
Author

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.

@xadahiya
Copy link
Member

@Guttz ^^

@chrizandr
Copy link
Member

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. :/

@AwesomeChap
Copy link
Author

AwesomeChap commented Oct 28, 2019

Anything you can do with a function, you can do with a class, but the opposite is not true.

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 useEffect can be used like componentDidMount, componentDidUnmount, and componentDidUpdate. React Hooks are very powerful, all depends on how we use them. Many firms using React our transforming their code bases to use functional components as code becomes much cleaner. So even if they scale, code readability and maintenance would not be a problem. I believe that current code base is going to scale in future (depending on changes/improvements/additions to hydra python agent). So that's why I suggested to use functional components. My stress is not on faster prototyping or fast paced development, but rather cleaner performant codebase, which is easy to read, debug and maintain (Which I think is important for an Open Source Project).

@Guttz
Copy link
Contributor

Guttz commented Oct 29, 2019

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.

@HTTP-APIs HTTP-APIs deleted a comment from kushalShukla-web Dec 9, 2021
@piy1577
Copy link

piy1577 commented Feb 21, 2023

I want to work on this issue please assign this issue to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants