Skip to content

Children forEach filters functions #9821

Closed
@neytema

Description

@neytema

React v15.5.4

Unexpected behaviour of React.Children.forEach – silently filters functions.

Current behavior:

const element = (
  <div>
    {() => {}}
    {() => {}}
  </div>
);
console.log(React.Children.toArray(element.props.children))
// Output: []

Expected behavior:

Children.forEach should throw Invariant error then function type child is met.

or

Children.forEach shouldn't filter function type children.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions