DEV Community

Discussion on: React folder structure

Collapse
 
seanmclem profile image
Seanmclem

If you have components that are pretty specific to a certain page -do you usually put them in a component folder within the page folder? Or always separately in the main components folder?

Collapse
 
woile profile image
Santiago

Is up to you how much flexibility you wanna have on your conventions. In my case a component related to a page only, can live inside that page folder. Because moving to the components folders it's actually super easy in case you have to.

For example you could have a folder Home where the Home/index.js exposes the full Home component, and inside there a Home/Clock.js component. If you need to reuse clock, it can be moved to components and you'd only have to update you Home to use the clock in components. It's a cheap refactor