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 vs Function components #56

Open
JohnRDOrazio opened this issue May 19, 2023 · 2 comments
Open

Class components vs Function components #56

JohnRDOrazio opened this issue May 19, 2023 · 2 comments
Labels
maintainability Ways to make sure the code is maintainable by the community

Comments

@JohnRDOrazio
Copy link
Collaborator

I'm noticing as I look over the source code, that sometimes components are written as class components, other times as function components. I'm guessing there's probably been some re-writing of the code over time. Is there any other specific reason for a different approach in how certain components are written? Or perhaps we could contribute to rewriting them using just one style? I think it would make for better readability and maintainability...

Actually I'm seeing that all components are Class components except one. Only WelcomeModal.js is written as a Function component. Personally I do prefer the Function component style...

@JohnRDOrazio JohnRDOrazio added the maintainability Ways to make sure the code is maintainable by the community label May 21, 2023
@kas-catholic
Copy link
Owner

I wrote most of the original source using class components. I don't have a strong opinion, I just hadn't written that much react and chose one.

Someone else contributed the WelcomeModal and happened to use a functional component.

I don't personally care too much one way or the other, but I'd be fine with rewriting things in the functional style for the sake of maintainability and consistency.

@kas-catholic
Copy link
Owner

I'm converting everything to function components as part of the Astro rewrite, so that will fix this. It does seem clear that function components are preferable in modern React code. Currently in development on the astro branch. (Preview)

I'll close this after that branch merges to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainability Ways to make sure the code is maintainable by the community
Projects
None yet
Development

No branches or pull requests

2 participants