繁体   English   中英

React + Redux,render()没有返回任何内容

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM