[英]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.