DEV Community

Discussion on: React folder structure

seanmclem profile image

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?

woile profile image
Santiago Author

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