[英]React + Redux, nothing returned from render()
从render()
返回的所有data
都不是array
并且它不是undefined
或为null
(已通过debugger
检查)。 迭代所有需要的数据,但是什么也没有返回。
如果需要,您可以在这里找到完整的代码: https : //github.com/BakuganXD/taskManager/tree/boardUpdate
Component.js:
class ProfilePage extends React.Component {
//several functions
render() {
const { loading, error, data, isEditing, editToogle } = this.props;
if (!loading && !error) {
{data.map( (value, index) => {
if (!isEditing[value.id]) {
return (
//a lot of JSX code, value is not undefined
} else {
return (
//another big JSX part
);
}
}
) }
} else return <p>Loading</p>;
}
}
您需要返回data.map
结果。 另外,删除data.map
周围的{}
class ProfilePage extends React.Component {
//several functions
render() {
const { loading, error, data, isEditing, editToogle } = this.props;
if (!loading && !error) {
return data.map( (value, index) => {
if (!isEditing[value.id]) {
return (
//a lot of JSX code, value is not undefined
)
} else {
return (
//another big JSX part
);
}
})
} else return <p>Loading</p>;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.