DEV Community

loading...

Lines of code vs more Files

martinramirezboggio profile image martinramirezboggio ・1 min read

Good day devs.
I've been going through a react project and found the common used Utils.js file with more than 600 lines of code from global constants, functions and really big functional components, for me this is really messy I prefer having the utils.js with no more than functions, constants in a constants.js file and each functional component in its own file.

I'd like to know what do you thing about this.

Thank you for your time.

Discussion (2)

pic
Editor guide
Collapse
zoedreams profile image
☮️✝️☪️🕉☸️✡️☯️

Util should contain static global functions which multiple base classes implement. Constants should contain your constants, and Strings should have your strings.

I also jam all my globals under global.App so it doesn't collide with other modules.

gl;hf;

Collapse
dividedbynil profile image
Kane Ong • Edited

You can put multiple small components in a single file too.