Encountered two children with the same key, `.${elem}`. Child keys must be unique; when two children share a key, only the first child will be used
See original GitHub issue发生问题的环境是:
- antd 版本: 2.3.1
- 操作系统及其版本: mac 10.12.1 (16B2555)
- 浏览器及其版本: 54.0.2840.87
您做了什么?请提供尽可能详细的重现步骤。
使用Select 及 Option组件时,使用map返回的数组在DOMWrap里key不唯一,option只返回渲染了第一个
代码: <Select> { list.map(function(elem, idx) { return ( <Option key={idx} value={elem}>{elem}</Option> ); }) } </Select>
报错:
Mention.js?9c0c:44 Warning: flattenChildren(…): Encountered two children with the same key, .${elem}
. Child keys must be unique; when two children share a key, only the first child will be used.
in ul (created by DOMWrap)
in DOMWrap (created by Menu)
in Menu (created by DropdownMenu)
in div (created by DropdownMenu)
in DropdownMenu (created by SelectTrigger)
in LazyRenderBox (created by PopupInner)
in div (created by PopupInner)
in PopupInner (created by Popup)
in Align (created by Popup)
in AnimateChild (created by Animate)
in Animate (created by Popup)
in div (created by Popup)
in Popup
您期待的结果是:
实际上的结果是:
可重现的在线演示
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
遇到同样的问题,你的<Option>如果用MAP实现时,必须有一个key键,同时,你的key的值也是你的value.
这样一个页面就能共享一个数组生成两个以上的select组件。就会报如标题的错误。
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.