React render: Objects are not valid as a React child

前端 未结 4 1701
自闭症患者
自闭症患者 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:14

    You need to wrap items in JSX in your return statement:

    return (
        
            {items}
        
    )
    

    Your final return statement currently is not inside JSX. It's plain old JavaScript that is constructing an object like {items: items} thanks to enhanced object literals, which is why React is saying you are giving it an item with key items.

提交回复
热议问题