Skip to content

Improve documentation for React.Children.only #87

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

Closed
bvaughn opened this issue Oct 8, 2017 · 4 comments
Closed

Improve documentation for React.Children.only #87

bvaughn opened this issue Oct 8, 2017 · 4 comments

Comments

@bvaughn
Copy link
Contributor

bvaughn commented Oct 8, 2017

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.

@renatoselenica
Copy link
Contributor

Can I take this one? If no one else is working on it right now.

@bvaughn
Copy link
Contributor Author

bvaughn commented Oct 9, 2017

This issue is all yours! 😄

I've added an "in-progress" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that I can remove the label and free it up for someone else to claim.

Cheers!

@renatoselenica
Copy link
Contributor

renatoselenica commented Oct 10, 2017

#118 I just submitted a pull request on it.
P.s. sorry I dont know how to do an actual pull request reference like the one above. Still new at this

@bvaughn
Copy link
Contributor Author

bvaughn commented Oct 10, 2017

No problem @renatoselenica.

For future reference, if your pull request description says something like "Fixes #87" then GitHub will automatically link the 2 and close the issue when the PR is merged.

jhonmike pushed a commit to jhonmike/reactjs.org that referenced this issue Jul 1, 2020
* Add function and class component to glossary

Following the changes made by the React team: reactjs#863.

* Sort glossary
BetterZxx pushed a commit to BetterZxx/react.dev that referenced this issue Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants