DEV Community

Discussion on: How I Organize React Projects

Collapse
 
alexandrudanpop profile image
Alexandru-Dan Pop

I for one also like having specific rules for folder structure. Would add a few things that correspond to how I structure code:

  • putting too many things in shared will create a lot of shared files that are actually used only in one area - so probably would put things in a feature folder and only move them to shared when they are actually shared
  • folders that specify the code type (component/class/reducers) are not really helping me explore the code. I might just open folders that have only one file. I instead collocate files - components, hooks, providers, whatever in their feature folder.
  • the main rule for organizing files and folders is by feature
Collapse
 
bytebodger profile image
Adam Nathaniel Davis

Sounds like our approaches aren't terribly different. It just seems like I'm more likely to put things in /shared by default, and you're more likely to put them in /routes (or however you name your "feature" directories) by default. Of course, with modern IDEs, it's usually pretty fast-and-simple to drag items into/out-of shared/features in the event that you feel they belong somewhere else in the future.

Thanks for the feedback!