Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear docs and API for children, esp. only children #7535

Closed
joshkel opened this issue Aug 20, 2016 · 1 comment
Closed

Unclear docs and API for children, esp. only children #7535

joshkel opened this issue Aug 20, 2016 · 1 comment

Comments

@joshkel
Copy link

joshkel commented Aug 20, 2016

I'm writing a table cell component that will specially handle the case where it's given a single number, and from looking at the documentation and API, I'm unclear on how to do this:

My questions, or suggestions for improvements to the docs:

  • Is this.props.children supposed to be opaque? If so, "Type of the children props" should be updated.
  • Or is it supposed to be public? If so, "Multiple Components" and "Top-level API" should be updated.
  • Can the documentation for React.Children.only be updated to clarify that it requires a valid React element and possibly to explain the use case for this requirement? (See comments on React.Children.onlyChild throws on text child #1104 for some of the confusion caused by the current documentation.)* What's the official or recommended way to get at the only "anything renderable" child, as opposed to the only "valid React element" child?
    • Changing React.Children.only to allow for string and number nodes was closed as won't fix (React.Children.onlyChild throws on text child #1104)
    • Using this.props.children directly goes against the docs' statement that it should be opaque.
    • Using React.Children.map or React.Children.forEach seems like overkill.

If this.props.children is supposed to be opaque, then would a new React.Children.onlyNode function be a useful solution?

@gaearon
Copy link
Collaborator

gaearon commented Oct 23, 2016

Some of these docs are gone now.
Let's track a separate "Manipulating Children" guide in #8060.
Would you like to work on it?

@gaearon gaearon closed this as completed Oct 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants