DEV Community

Discussion on: Architecting React Applications

Collapse
 
insidewhy profile image
insidewhy • Edited

Why would I put all my components in a directory called components just because they are components? Then each feature is split across several subdirectories? Even weirder, a constants directory? A hooks directory? Who cares what the nature of a thing is so much that it should be put in a directory named after it?

This kind of organisation really sucks by pretty much any criteria and really doesn't scale. Why early react projects started out structured like this I have no idea, but it's time we let this method of organisation die. Organising by feature is so much nicer. Everything is grouped with related code. Subfeatures can be nested. I can load and see all related code in one directory, and maybe its subdirectories also. I don't have giant directories with hundreds of files in them.

If for some reason you really want to have folders called components and constants, then do it the other way round, and nest them within the feature directories.

Collapse
 
pedrovelborr profile image
Pedro Velazquez

Thanks for your feedback.