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.
Loading...
Related Quiz
- What is context?
- How to use FormattedMessage as placeholder using React Intl?
- If you want to navigate between different screens in a React Native application, which library/package is commonly used?
- Is it keys should be globally unique?
- You're building an e-commerce platform and need to apply different styles based on the user's selected theme. Which React library would be most suitable to dynamically style components?