Skip to main content
Rlgo

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,
]

Reference #

https://youtube.com/shorts/Gz9xnlE6i98?si=hka7vn9W_K0PLgUK