Which TypeScript feature allows you to specify types for props and state in class components?

  • Decorators
  • Generics
  • JSX syntax
  • Type assertions
Generics is the TypeScript feature that allows you to specify types for props and state in class components. By using generics, you can create reusable components that can work with different data types. While JSX syntax is used for rendering React components, type assertions are used to explicitly specify a type, and decorators are used for metadata annotations, but they are not the primary TypeScript feature for specifying types in class components.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *