- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
当我尝试映射和显示我从外部 API 获得的项目时,我收到错误消息说有相同 key 的 child ,即使我知道 ID 不同并且只显示第一张卡片。
这会引发错误,如果我使用 {test.id}
也没关系或 {index}
作为关键:
{tests.map( test =>
<Col span="8" xs={{span:22}} md={{span:6}} key="{test.id}">
<Card title={test.title} bordered={false}>{test.content}</Card>
</Col> )}
但另一方面,当我尝试以简单的方式显示它时 <ul>
:
{tests.map( test =>
<li className="list-group-item" key={test.id}>
{test.title}
</li>
)}
一切正常,我显示了我收到的所有元素。
我对 React 和 Redux 还是个新手,所以我不确定去哪里寻找解决方案。
非常感谢。
最佳答案
改变这一行:
<Col span="8" xs={{span:22}} md={{span:6}} key="{test.id}">
到
<Col span="8" xs={{span:22}} md={{span:6}} key={test.id}>
{test.id}
用双引号括起来使它成为一个字符串,所以它总是一样的。
关于javascript - react 警告 : flattenChildren(. ..) : Encountered two children with the same key, `.${index}`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43432261/
我看过this same issue但无法弄清楚我的错误在哪里。 我的实时搜索框工作得很好,但是一旦你删除了你的搜索查询(单词),警告就会出现在 react 控制台中: Warning: flatte
我正在使用 Material UI 中的选项卡,其中显示按选项卡筛选的列表组件,请参阅我的容器组件中选项卡的代码:
有人可以解释一下如何修复此错误 Warning: flattenChildren(...): Encountered two children with the same key 我已经复制了下面的代
我知道这个问题之前已经被问过,但我不确定我是否理解这里发生的事情。我有一个对象数组,我在 React 组件中映射它们以创建导航:某些元素可能有子元素,因此我为这些元素添加第二个 .map 函数。一切正
我正在尝试创建一个列表并使其可点击,以便一旦我点击某个项目,我就会重定向到另一个页面 这是渲染方法 render() { const quesItems = this.state.questions
每次我两次点击抽屉中的相同元素时,我都会收到以下警告: Warning: flattenChildren(...): Encountered two children with the same ke
当我尝试映射和显示我从外部 API 获得的项目时,我收到错误消息说有相同 key 的 child ,即使我知道 ID 不同并且只显示第一张卡片。 这会引发错误,如果我使用 {test.id} 也没关系
我收到了大量此类错误,一个接一个,警告消息中附加了不同的键。有没有办法根据 id key 找出它们来自哪里? 最佳答案 找出哪里犯了关键错误通常是一件很痛苦的事情,而在 React 15 中,data
昨天我将 react-router-dom 添加到我的项目中,现在当我离开并返回导航中的 Sky 元素时,它会重新加载天空,我得到 Warning: flattenChildren(...): Enc
我是一名优秀的程序员,十分优秀!