React错误:无法在“Node”上执行“insertBefore”:要插入新节点的节点不是该节点的子节点

Apu*_*rvG 5 javascript reactjs simplebar

我正在尝试映射从 api 调用获得的响应。我想在这张地图上渲染一个div。这就是我的代码的样子:

<div data-simplebar className="img-scroll">
    {this.state.imageSearchResults.items.map((item, ind) => {
        return <div className="image-square" style={{backgroundImage:`url(${this.state.imageSearchResults.items[0].link})`}}></div>
    })}
</div>
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息

Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
Run Code Online (Sandbox Code Playgroud)

这有什么问题吗?我过去也以同样的方式进行过映射,但从未遇到过这样的错误。

Den*_*nge 1

key给孩子添加合理的道具。