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

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

    I hope it will help someone else.

    This error seems to occur also when you UNintentionally send an object to React child components.

    Example of it is passing to child component new Date('....') as follows:

     const data = {name: 'ABC', startDate: new Date('2011-11-11')}
     ...
     
    

    If you send it as value of a child component parameter you would be sending a complex Object and you may get the same error as stated above.

    Check if you are passing something similar (that generates Object under the hood).

提交回复
热议问题