DEV Community

Discussion on: Screaming Architecture - Evolution of a React folder structure

Collapse
 
develliot profile image
Develliot • Edited

I used to do something similar to this but now I just have /pages (because of next js I have to) and /components and /hooks ect are completely flat.

Each component will be a folder containing a single file of code, a styles file and potentially a test file. It's always a folder even if it has a single file so it's alway in alphabetical order it doesn't list the folders and then the single files in the IDE.

The moment you start having file hierarchies you start needing knowledge of the app to traverse it to find stuff. Also if you have a reusable component the you start having a "shared" location so now a file could be in shared or somewhere in the hierarchy or duplicated. If you keep it flat it's going to be huge but if you have a complicated app your going to have loads of features anyway.

When you try to find stuff you start with the page/route and you work your way in and you can see the list of components the whole time.