-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Children.map & Co do not traverse keyed Fragments #13677
Comments
I think that the test I have added in #13679 also demonstrates the bug by failing |
I don't think this is a bug actually, it's been discussed a few times in other issues and I believe the consensus was that it's intended that fragments be distinct elements vs an array of elements |
@jquense so is this a bug in the documentation? |
Sounds like it but let's wait for a core team member to confirm |
Some way to automatically “flatten” the |
Yes, it is intentional that |
After more searching I have found this comment by Dan Abramov:
Which I interpret as this implementation not being particularly intentional. He then proposes to submit an RFC for these changes, but I couldn’t find any at the moment. I will try to create one now. |
Maybe, although for what it's worth I talked to him to confirm this was intentional earlier yesterday:
That being said, an RFC sounds like the right way to go 👍 |
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
The documentation on React.Children.map tells us that "If children is a keyed fragment or array it will be traversed: the function will never be passed the container objects." This demo shows that arrays are indeed traversed, but the keyed fragments are not traversed. Open the developer console and click "Run" to see the output.
What is the expected behavior?
Children.map, forEach, toArray, count should traverse keyed Fragments as per documentation.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
The example runs on v16.5.1, but I have also seen that fail locally on v16.4.2. I never tried this before so I don’t know if this ever worked. I see it fail in latest Firefox and Chrome on Ubuntu Linux.
The text was updated successfully, but these errors were encountered: