Design Patterns · Middle · Question 42 of 75
Which pattern is used in component "slots" (<Card header={...} footer={...}>)?
- ✓Correct answer: Composition via props: a skeleton plus passed-in content
- 2Inheritance:
CardextendsHeaderandFooter - 3Singleton: a page can have only one card
Explanation
Slots (children, named props with JSX) let you extend a component without adding a flag for every case. It's a direct application of "composition over inheritance" and OCP.