简体   繁体   中英

React + Redux, nothing returned from render()

Nothing returned from render() , data is an array and it's not undefined or null (checked with 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

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. Also, remove {} around 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>;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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