Javascript react函数不呈现任何内容
我在react.js中呈现ajax数据时遇到问题。 在我的渲染函数中,我有Javascript react函数不呈现任何内容,javascript,reactjs,redux,Javascript,Reactjs,Redux,我在react.js中呈现ajax数据时遇到问题。 在我的渲染函数中,我有 {!isLoading && this.renderList(items) } 我的renderList函数如下所示 renderList(items) { ... ... const renderLi = (statusObj) => { return ( <h1> something </h1> ) } status
{!isLoading &&
this.renderList(items)
}
我的renderList函数如下所示
renderList(items) {
...
...
const renderLi = (statusObj) => {
return ( <h1> something </h1> )
}
statusList.map(renderLi);
}
renderList(项目){
...
...
常量renderLi=(statusObj)=>{
归还(某物)
}
statusList.map(renderLi);
}
我怀疑这是异步问题,我在我的renderList中控制台项它确实通过参数传递获得了对象数组,我丢失了。您的cod中的问题是您没有从
renderList
函数返回任何内容,因此没有任何内容得到渲染
您的返回声明将被删除
{!isLoading &&
this.renderList(items)
}
您的renderList
函数如下
renderList(items) {
...
...
const renderLi = (statusObj) => {
return ( <h1> something </h1> )
}
return (<div>{statusList.map(renderLi)}</div>);
}
renderList(项目){
...
...
常量renderLi=(statusObj)=>{
归还(某物)
}
返回({statusList.map(renderLi)});
}
返回状态列表.map(renderLi)代码>?我看到另一个问题-呈现函数应该只返回一个根元素,最好是“return{statusList.map(renderLi)}”@AlexPashkin我找到你了,我使用了双返回,它工作了。@AndyRay有什么线索说明为什么在这种情况下需要返回两次吗?你说的很管用,谢谢!!renderLi是一个在内部返回的函数。renderList也是一个需要从中返回的函数。