Component Driven Development
Save money and time building user interfaces from tested modular components
By referencing a Design System, CDD enables designers and developers to collaborate more efficiently.
Components are standardised, interchangeable building blocks that encapsulate the appearance and function of UI pieces.
Think LEGO bricks. LEGOs can be used to build everything from castles to spaceships; components can be taken apart and used to create new features.
Component Checklist
- Always name your React components
- Write consistently organized components
- Separate constants and helpers into different files
- Destructure props
- Don't pass a ton of props in
- Avoid nesting render functions
- Conditional rendering practices
- Assign default props when destructuring
Component Types
Components generally fit into three distinct classes:
- Presentational
- Structural (Composite)
- Stateful
These three categories are a discovered pattern rather than an imposed one — components are not created to fit these categories, but components organically show these characteristics.
Other terms
- Dumb vs Smart Components
- Presentational vs Container Components
- Pure vs Stateful Components
Presentational
Emerge quickly when we build component libraries, as typically all components in a component library can be understood to be built to be reusable and purely presentational, agnostic to what API or application state they're rendered with. They may abstract our styles and theming, concern themselves more with our users' interactions with the app, and provide a thin API layer to be used in other components.
Structural
Whenever we think of "screens," "views," or "pages." These components emerge as we compose presentational components into a structure that represents our app's views and will often distribute our backend's data throughout the app. They compose presentational components and are hence a mapping of our business logic and application state and data.
Stateful
Every app has places where it integrates backend data and business logic to feed into views, generally understood as state. This state is different from our presentational components' local state.
Design Process
- Research and planning
- Component library
- Write providers and hooks for your backend data fetching
- Split app into views and pages