React render: Objects are not valid as a React child

前端 未结 4 1712
自闭症患者
自闭症患者 2020-12-21 06:03

Please help me. I don\'t know why this piece of code doesn\'t work.

It gives me an error: \"Objects are not valid as a React child (found: object with keys {itemss})

4条回答
  •  长情又很酷
    2020-12-21 06:34

    here you go:

    return (
        
    {items.map(i) => (

    {i.title}

    )}
    )

    edit: in react, return/render can not have a structure like

    {i.title}

    {i.title}

    {i.title}

    you should wrap them in a

    or another element. also you JS was wrong which I corrected

提交回复
热议问题