Skip to content

Improve documentation for React.Children.only #87

Closed
@bvaughn

Description

@bvaughn

This issue was originally reported by @jimfb via facebook/react/issues/4424

Please refer to the original issue for the related discussion thread.

My understanding of the outcome is that the docs and the implementation are slightly misaligned. The docs currently say:

Returns the only child in children. Throws otherwise.

This is somewhat ambiguous though with regard to how it handles an array with only 1 child element. The actual implementation uses a helper method to verify that the child is an object (eg not in an array).

Let's add some clarification to the docs about exactly what this method does.

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