简体   繁体   English

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

[英]React + Redux, nothing returned from render()

Nothing returned from render() , data is an array and it's not undefined or null (checked with debugger ). render()返回的所有data都不是array并且它不是undefined或为null (已通过debugger检查)。 It iterate all needed data but then nothing returned. 迭代所有需要的数据,但是什么也没有返回。

Here you can find full code if it needed: https://github.com/BakuganXD/taskManager/tree/boardUpdate 如果需要,您可以在这里找到完整的代码: https : //github.com/BakuganXD/taskManager/tree/boardUpdate

Component.js: 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>;
 }
}

You need to return data.map results. 您需要返回data.map结果。 Also, remove {} around 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