Component Composition:
write code Modular, reusable, Readable, Testable
first Do Component design before start writing code. it will make your code modular reusable readable, testable, it will be require less refactoring and it will helpful in State management and write proper CSS.
SOLID principle
follow single responsibility principle in component design as well
when you have the correct component design it will very easy to test your component, it will introduce less bug and it will be introduce fewer bugs.
Higher Order Components => takes component as input and return a component with extra feature.
i.e new Card component will take card component and return a new component with adding new Lable on it.
Take example of Make my trip. it have Flights, Hotels, Holiday packages and many more. let’s say each have 100 components inside it.
if we don’t do proper component design and load all all components then it will create a lot of issue.
by doing proper component design it will be easier to do lazy loading, chunking, code splitting .. and many more optimization.