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

前端 未结 11 2584
悲&欢浪女
悲&欢浪女 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 08:00

    Although not specific to the answer, this error mostly occurs when you mistakenly using a JavaScript expression inside a JavaScript context using {}

    For example

    let x=5;
    
    export default function App(){ return( {x} ); };
    

    Correct way to do this would be

    let x=5;
    export default function App(){ return( x ); };
    

提交回复
热议问题