DEV Community

Cover image for 10 Concerns & How we can make the whole React codebase cleaner

10 Concerns & How we can make the whole React codebase cleaner

Ashish Surana on October 20, 2019

Creating a project from scratch is easy but shipping features after some time become very difficult and that comes with a cost of delays, bugs and ...
Collapse
 
ibibgor profile image
Oscar

For the comments tip you gave, I have to say that we in our team allow comments. But they should not explain what is done at a specific code block but explain WHY it was done that way. Maybe it's a little hacky solution but necessary because of dependencies. Therefor other developer should not waste time on trying to refactor some code only to realise that this code is "the currently best option"

But: Nice post! I'm happy that we do the most of those patterns and tips ourself already :)

Collapse
 
ashishsurana profile image
Ashish Surana

Absolutely correct. 100% Agree with you. Comments are not a bad practice at all, but enforcing comments above every single function, variable declaration leads to bad code. We are also following comments for a business logic explanation so that other engineers can quickly get the context and understand the use case.

Collapse
 
ronnewcomb profile image
Ron Newcomb

Depending on codebase, #5's propTypes has been replaced by "use Typescript".

Good article though.

Collapse
 
ashishsurana profile image
Ashish Surana

Yes, Using Flow and Typescript gives you way more flexibility and advantages as compared to propTypes because they can be beneficial in pure functions as well as react components.
Thanks a lot for opinion.