Objects are not valid as a React child. If you meant to render a collection of children, use an array instead

前端 未结 11 2600
悲&欢浪女
悲&欢浪女 2020-11-28 07:28

I am setting up a React app with a Rails backend. I am getting the error \"Objects are not valid as a React child (found: object with keys {id, name, info, created_at, updat

11条回答
  •  悲&欢浪女
    2020-11-28 07:45

    Well in my case the data which I wanted to render contained an Object inside that of the array so due to this it was giving error, so for other people out there please check your data also once and if it contains an object, you need to convert it to array to print all of its values or if you need a specific value then use.

    My data :

    body: " d fvsdv"

    photo: "http://res.cloudinary.com/imvr7/image/upload/v1591563988/hhanfhiyalwnv231oweg.png"

    postedby: {_id: "5edbf948cdfafc4e38e74081", name: "vit"} //this is the object I am talking about.

    title: "c sx "

    __v: 0

    _id: "5edd56d7e64a9e58acfd499f"

    proto: Object

    To Print only a single value

    {item.postedby.name}

提交回复
热议问题