All articles

How To Craft Flexible UIs In React by Using Generic And Domain Components? ๐Ÿ’ช

That's part of my book "The Conscious React" ๐Ÿ“š

Petar Ivanov

2 min read

On this page

Iโ€™ve worked on various React projects and codebases in the last couple of years.

From small e-commerce clients to big enterprise clients.

Iโ€™ve seen how different codebases become tangled, hard to maintain, and develop.

Or how business requirements change and you must refactor most of the app.

In one of these projects, my team and I decided to take a more strategic approach: split components into Generic and Domain categories.

This helped us create more modular, reusable code while addressing the new business needs and requirements.


What Are Generic Components?

Generic components handle common tasks not tied to specific business or domain requirements.

These components provide a solid foundation and can be reused across all pages, no matter the context.

For example: buttons, text inputs, forms, modals, cards, etc.


What Are Domain Components?

Domain components are built on top of these Generic components.

Domain components built on top of generic components

They address the unique needs of your product and business context.

For example, a <BackButton /> might build on Generic <Button /> to handle navigation in a product-specific way.

BackButton domain component built on the generic Button component


Why Splitting Components Into Generic And Domain?

  1. Reusability: Generic components are easy to reuse in new features or across different projects.
  2. Maintainability: When business requirements change, you only update the Domain components while the Generic ones stay the same.
  3. Consistency: By having a set of standard building blocks, you product and business look and feel stays consistent.
  4. Scalability: Over time, you can evolve the set of Generic components into a separate UI component library.

๐Ÿ“˜ If you like thinking about component boundaries this way, my book The Conscious React is full of it โ€” 100+ production tips on React architecture, design, and clean code.

๐Ÿ“‹ Recap

  • Prefer creating many reusable Generic components that can be further extended and composed into more specific Domain components.
  • Splitting components into Generic and Domain categories helps your codebase to be more reusable, maintainable, consistent, and ready to scale.

Written by

Petar Ivanov

Software engineer, author and speaker. I help JavaScript developers grow from mid-level to senior to architect, with production-grade React, Node.js and AI systems.

Whenever you're ready, here's how I can help you:

  1. 1

    The Conscious React: React architecture, design and clean code. 100+ production tips across 6 chapters, updated for React 19, plus 4 companion repos you can clone and run.

  2. 2

    The Conscious Node: Node.js architecture, design and clean code. 157 production tips across 10 chapters, from module boundaries to the transactional outbox and zero-downtime deploys.

  3. 3

    The JavaScript Architect Bundle: Both Complete Packages in one purchase, with the two books, all 7 React and Node companion repos and the AI rules files.

  4. 4

    Free Resources: Architecture playbooks, cheat sheets and the JavaScript Architect Roadmap. Practical guides for the move to senior.