You may have returned undefined, an array or some other invalid object rendering state data

后端 未结 4 1643
被撕碎了的回忆
被撕碎了的回忆 2021-01-26 07:11

Have been facing issue while iterating through a list and printing elements in React.

The React Code is:

import React from \'react\';
import ReactDOM fro         


        
4条回答
  •  无人共我
    2021-01-26 07:33

    Change like this, While you using map should use key attribute for index

    makeUI() {
            if(!this.state.myData.length)
                return
    
            return this.state.myData.map((item, index) => {
            return (
                

    {item.title}

    {item.description}

    ) }) } render() { return (
    { this.makeUI() }
    ) }

提交回复
热议问题