Skip to content

QuizNot attempted

ReactNode vs JSX.Element for children

A Layout must accept text, null, an array of elements or a single element as children. Which prop type fits?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • React.ReactNode
  • ReactNode is everything React can render: elements, strings, numbers, null/undefined/booleans, iterables of those, and (React 19) promises, so it is the right type for children.
  • Not React.JSX.Element: that is only the result of a JSX expression, so null, 'text' and arrays are rejected.
  • Not React.ReactElement: same problem, it is a single element object.
  • Not string | React.JSX.Element: still misses null, numbers and arrays.
  • React 19 types also dropped the global JSX namespace, so write React.JSX.Element when you do need it.