我正在尝试映射从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>
我收到一个错误,说
Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
这有什么问题呢?我在过去做过同样的映射,从来没有得到过这样的错误。
发布于 2019-01-24 21:07:14
<div data-simplebar className="img-scroll">
你使用的是simplebar插件,它改变了DOM树并破坏了React。尝试使用React的package 'simplebar-react‘,它可以正常工作。
import SimpleBar from 'simplebar-react';
<SimpleBar>
...
</SimpleBar>
发布于 2021-01-08 17:51:03
如果有人在Google Chrome中翻译页面时偶然发现了这个问题,很可能与以下内容有关:
https://github.com/facebook/react/issues/11538
我的Chrome团队还没有解决的老问题。
https://bugs.chromium.org/p/chromium/issues/detail?id=872770
发布于 2021-08-22 14:28:12
在<p> or <span>
中包装可翻译的文本为我解决了问题
https://stackoverflow.com/questions/48691283
复制相似问题