JSX.Element vs React.ReactNode
ReactNode #
ReactNode represents anything a React component can render
const examples: React.ReactNode [] = [
<div />,
"Hello!",
123,
undefined,
]
JSX.Element #
JSX.Element only represents JSX
const examples: React.ReactNode [] = [
<div />,
// Type 'string' is not assignable to type 'Element'
"Hello!",
// Type 'number' is not assignable to type 'Element'
123,
// Type 'undefined' is not assignable to type 'Element'
undefined,
]