Quiz
In this quiz, we will test what we have learned about strongly-typed function component props with TypeScript
Creating strongly-typed function props
1
Below is a component for a red button:
const RedButton = ({ children }) => (
<button style={{ backgroundColor: "red" }}>{children}</button>
);
What type annotation can we use to strongly type the props of the button? (There is more than one correct answer).
A)
const RedButton: React.SFC = ({ children }) => ...
B)
const RedButton: React.FC = ({ children }) => ...
C)
const RedButton: React.Component = ({ children }) => ...
D)
const RedButton = ({ children }: {children: React.ReactNode}) => ...
Question 1 of 50 attempted
Get hands-on with 1400+ tech skills courses.