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

前端 未结 11 2579
悲&欢浪女
悲&欢浪女 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:43

    I had a similar error while I was creating a custom modal.

    const CustomModal = (visible, modalText, modalHeader) => {}
    

    Problem was that I didn't wrap my values to curly brackets like this.

    const CustomModal = ({visible, modalText, modalHeader}) => {}
    

    If you have multiple values to pass to the component, you should use curly brackets around it.

提交回复
热议问题