DEV Community

Discussion on: 4 Ways to Render JSX Conditionally in React

Collapse
 
danwalsh profile image
Dan Walsh

If I remember correctly, return on its own infers a return type of void, whereas return null is an acceptable React.ReactNode return type, as far as TypeScript is concerned.

Thread Thread
 
fjones profile image
FJones

And void in turn results in undefined on the caller, which React now supports, but I would still discourage. The reason support for it was added was, in part, inconsistency between nested and root-level conditional rendering.