Skip to content

Bug: Best practice - React.createElement children argument to be always array. #18361

Description

Maintain consistency

When a parent component contains children, sometimes it is passed as an object and sometimes it is passed as an array.

Example:
<Parent> <Child></Child> </Parent>

In the above example, typeof Parent.children will be object whereas

<Parent> <Child></Child> <Child></Child> </Parent>

typeof Parent.children will be Array.

The current behavior

Single child is treated as object and List of child is treated as array.

The expected behavior

Single child and list to be treated as an array of children.

Example

https://codesandbox.io/s/mystifying-antonelli-j4qe3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions