When you want a component to accept any type of prop but with certain constraints, you can make use of TypeScript's ________.
- any
- generic
- union
- unknown
TypeScript's unknown type is used when you want a component to accept any type of prop but with certain constraints or type checking. It's more restrictive than any as you must perform type assertion or type checking before using values of type unknown. It provides better type safety.
Loading...
Related Quiz
- How to apply validation on props in React?
- The method used to create a portal in React is called ________.
- How do CSS-in-JS libraries like styled-components handle server-side rendering (SSR) for styling?
- For fetching data before rendering a component in a route, you might use the React Router's ________ method.
- The Redux concept that ensures every action returns a new state object, ensuring immutability, is called ________.