QuizNot attempted
React.FC and children
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- No:
FCno longer addschildren; declarechildren: React.ReactNode(or usePropsWithChildren<P>)
- Since
@types/react18,FC<P>is just(props: P) => ReactNode, so passing children to a component whose props don't declare them is an error - add
children: React.ReactNode(or wrap withPropsWithChildren<P>) when the component really renders them. - Not 'FC always includes children implicitly': that was the React 17 typing, removed because it let components silently accept children they ignored.
- Not typed as any: there is no implicit
childrenat all. - Not 'never receive children': they can, once
childrenis in the props type.