Javascript &引用;TypeError:无法读取属性';第一个孩子';“未定义”的定义;在React JSX中执行循环时

Javascript &引用;TypeError:无法读取属性';第一个孩子';“未定义”的定义;在React JSX中执行循环时,javascript,reactjs,Javascript,Reactjs,当我试图在render方法中循环一个数组时,我得到以下错误: Warning: React can't find the root component node for data-reactid value `.1zdr3j32tc0.0`. If you're seeing this message, it probably means that you've loaded two copies of React on the page. At this time, only a single

当我试图在
render
方法中循环一个数组时,我得到以下错误:

Warning: React can't find the root component node for data-reactid value `.1zdr3j32tc0.0`. If you're seeing this message, it probably means that you've loaded two copies of React on the page. At this time, only a single copy of React can be loaded at a time.

/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactMount.js:715
    firstChildren[0] = deepestAncestor.firstChild;
                                      ^
TypeError: Cannot read property 'firstChild' of undefined
    at Object.ReactMount.findComponentRoot (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactMount.js:715:39)
    at Object.ReactMount.findReactNodeByID (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactMount.js:679:23)
    at Object.getNode (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactMount.js:162:32)
    at Object.ReactDOMIDOperations.dangerouslyProcessChildrenUpdates (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactDOMIDOperations.js:83:42)
    at Object.wrapper [as processChildrenUpdates] (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactPerf.js:66:21)
    at processQueue (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactMultiChild.js:160:31)
    at ReactDOMComponent.ReactMultiChild.Mixin.updateChildren (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactMultiChild.js:334:13)
    at ReactDOMComponent.Mixin._updateDOMChildren (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactDOMComponent.js:871:12)
    at ReactDOMComponent.Mixin.updateComponent (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactDOMComponent.js:700:10)
    at ReactDOMComponent.Mixin.receiveComponent (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactDOMComponent.js:645:10)
    at Object.ReactReconciler.receiveComponent (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactReconciler.js:87:22)
    at [object Object].ReactCompositeComponentMixin._updateRenderedComponent (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactCompositeComponent.js:562:23)
    at [object Object].ReactCompositeComponentMixin._performComponentUpdate (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactCompositeComponent.js:544:10)
    at [object Object].ReactCompositeComponentMixin.updateComponent (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactCompositeComponent.js:473:12)
    at [object Object].wrapper [as updateComponent] (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactPerf.js:66:21)
    at [object Object].ReactCompositeComponentMixin.performUpdateIfNecessary (/home/anass/Dropbox/projects/code/elbotola/elbotola_react/node_modules/react/lib/ReactCompositeComponent.js:421:12)
我的组件看起来像这个LatestNews.jsx文件

从“React”导入React;
“超级代理”的进口请求;
从“力矩”中导入力矩;
类LatestNews扩展React.Component{
建造师(道具){
超级(道具);
this.state={articles:[]};
}
fetch(){
要求
.get('http://api.localhost.com/articles/')
.end((错误、恢复)=>{
如果(res.ok){
this.setState({articles:res.body.results});
}
});
}
组件willmount(){
this.fetch()
}
render(){
返回(
{this.state.articles.map(post=>{
回归试验;
})}
);
}
}
导出默认最新新闻;
如果这有帮助:

  • 这是通过使用
  • 渲染将发生。但是错误发生后,服务器不再响应任何请求
  • 我正在使用React路由

我不确定我做错了什么。

@Hacketo-Fixed。谢谢那个打字错误可能是在我格式化代码时滑倒的。它是用代码正确编写的。是否确认没有包含React的两个副本,正如堆栈跟踪的第一行所警告的那样?
find./-name“React”
仅返回
/node\u modules/React
。我的呈现HTML只包含一个app.js文件。还有其他方法可以检查吗?我怀疑在启动回调时,组件已经卸载,生成的DOM被推送到浏览器上,但我对服务器端的响应没有足够的经验来确认。@Anass-你在这里解决过这个问题吗?在我的应用程序中,我看到类似的间歇性行为。我希望修复。谢谢那个打字错误可能是在我格式化代码时滑倒的。它是用代码正确编写的。是否确认没有包含React的两个副本,正如堆栈跟踪的第一行所警告的那样?
find./-name“React”
仅返回
/node\u modules/React
。我的呈现HTML只包含一个app.js文件。还有其他方法可以检查吗?我怀疑在启动回调时,组件已经卸载,生成的DOM被推送到浏览器上,但我对服务器端的响应没有足够的经验来确认。@Anass-你在这里解决过这个问题吗?我在我的应用程序中看到类似的间歇性行为。