[Question] JSX.Element vs React.ReactNode once again #129
Closed
Description
Hi. The Basic README claims that React.ReactNode
is preferable to JSX.Element
as a return value of a component because JSX.Element
is a return type of React.createElement
which is not, to put it simple, wide enough. Hovewer, when I attempt to use both to define the return type of a component, JSX.Element
fits and React.ReactNode
does not:
let C1 = (): JSX.Element => <div>test</div>
let c1 = <C1 />; // fine
let C2 = (): React.ReactNode => <div>test</div>
let c2 = <C2 />; // JSX Element type ReactNode is not a constructor function for JSX elements
// Type undefined is not assignable to type Element | null
What am I doing wrong?