TypeScript · Junior · Question 22 of 75
What's the right way to type a React component's props?
- ✓Correct answer:
function Button({ label }: { label: string })or viatype Props - 2
function Button(props: any)- React types props by itself - 3
function Button<label: string>()- props are passed as a generic
Explanation
Props are a plain object, typed with an interface or a type alias. React.FC isn't required. For children use React.ReactNode; to extend native attributes, use React.ComponentProps<'button'>.