-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Closed
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
From the docs (https://reactjs.org/docs/fragments.html#keyed-fragments):
function Glossary(props) {
return (
<dl>
{props.items.map(item => (
// Without the `key`, React will fire a key warning
<React.Fragment key={item.id}>
<dt>{item.term}</dt>
<dd>{item.description}</dd>
</React.Fragment>
))}
</dl>
);
}If I do this:
renderer
.create(
<Glossary
items={[{ id: 'id', term: 'term', description: 'description' }]}
/>
)
.toJSON();The result is:
{
"type": "dl",
"props": {},
"children": [
{ "type": "dt", "props": {}, "children": ["term"] },
{ "type": "dd", "props": {}, "children": ["description"] }
]
}If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).
See above
What is the expected behavior?
That, somehow, the key is not lost. I'm not sure where it would make sense, but it should be in there somewhere.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.2.0
nbluis