It's not uncommon to have a React component that takes props where some of those props are mutually exclusive. Let's imagine a case where we have a Button component. We want our button to allow for the following possibilities:
- The button has text.
- The button has text and an icon.
- The button has an icon, but no text.
An initial implementation might look like:
const Button = ({ text, icon }: { text?: string; icon?: string }) => {