Skip to content

Update inaccurate mapChildren comment#18931

Merged
gaearon merged 1 commit into
masterfrom
map-children-comment
May 15, 2020
Merged

Update inaccurate mapChildren comment#18931
gaearon merged 1 commit into
masterfrom
map-children-comment

Conversation

@rickyvetter
Copy link
Copy Markdown
Contributor

The function you provide will only be passed a child and an index. It will not be passed a key. This is confirmed in the source, the Flow types, and the jsdoc comments.

Summary

I was actually looking for a child map api that would expose keys and noticed this comment. It gave me the wrong impression and took a few minutes to re-affirm my understanding of React.Children and how it works. Removing this inaccuracy to hopefully prevent a similar misunderstanding in the future.

Test Plan

I ran absolutely no tests. This is a non-jsdoc comment-only change.

The function you provide will only be passed a child and an index. It will not be passed a key. This is confirmed in the source, the Flow types, and the jsdoc comments.
@sizebot
Copy link
Copy Markdown

sizebot commented May 15, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against bbda3d9

@codesandbox-ci
Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bbda3d9:

Sandbox Source
goofy-smoke-5kdkf Configuration

@sizebot
Copy link
Copy Markdown

sizebot commented May 15, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against bbda3d9

@gaearon gaearon merged commit 121af31 into master May 15, 2020
@gaearon
Copy link
Copy Markdown
Collaborator

gaearon commented May 15, 2020

Note it should care of merging with the old key automatically.

@rickyvetter
Copy link
Copy Markdown
Contributor Author

Thanks for the note. Reading through the source really changed how I view the "keyed-ness" of an element. I'm glad I did.

@kassens kassens deleted the map-children-comment branch November 29, 2022 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants