Conditional Types Example - React Component Props
This lesson shows a real-life usage of conditional types in React.
We'll cover the following...
Detecting a React component
How can we take advantage of conditional types and use them to extract the types of React component properties? Let’s create a conditional type that checks whether a given type is a React component.
type IsReactComponent<T> =
T extends React.ComponentType<any> ? "yes" : "no";
...