DEV Community

Discussion on: ReactJS: Component everything or not?

Collapse
 
t49tran profile image
Duong Tran

Thinking in react is actually a good read if you're still in doubt about when should you create a component: reactjs.org/docs/thinking-in-react....

The question When should you create a component ? can be best answered by answering another question Why should you create a component ?. Reason for creating new components are:

  • You want to reuse the code, and you want to keep your code DRY.
  • You want each component to have a specific and meaningful purpose, to have a Single Responsibility.
  • You want to keep different layers of the app (such as data, presentation and any other middle layers) separately, to follow Separation of Concerns pattern.