Skip to content

Returning an empty fragment throws a confusing error #12964

@aweary

Description

@aweary

https://codesandbox.io/s/40j50607y0

Rendering a component like:

const Foo = () => <React.Fragment />

Throws the error:

Foo(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

The error is confusing because clearly Foo is returning a value. I don't know if we want to support rendering empty fragments, but in any case this error is confusing.

If this isn't allowed it should explicitly call out that a component cannot return a fragment with no children.

cc @gaearon

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions