-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
React.Children.toArray changes element.key #5541
Comments
don't you want to use one of these: |
Thanks for your answer @liesislukas but i don't looking for workarounds about this. One more question i forgot: |
Yes, key is used to signal to React the identity of an object, and React.Children.toArray changes the key so that the identity semantics can be preserved. For example: <div>
<span key="header" />
{items.map((item) => <span key={item.id} />)}
</div> If any item has an If you want to read the key back off and have it unchanged (or to read it from within the component in |
Okay, thanks @spicyj ! |
@sophiebits Could you please provide an example showing why React prefixes keys this way when using |
React.Children.toArray changing the childrens key property. ex.:
"foo" => ".$foo"
In 0.14 sometimes (i dont know exactly when but event without
toArray
) i got even weirder keys when i parsing children. ex.: "foo" => "foo/.$foo"I didn't found any mention of these things yet.
Is it documented somewhere?
Can i get the original key somehow?
The text was updated successfully, but these errors were encountered: