Uncaught Error: Objects are not valid as a React child (found: Error: Objects are not valid as a Rea

Uncaught Error: Objects are not valid as a React child (found: Error: Objects are not valid as a React child (found: object with keys {name}). If you meant to render a collection of children, use an array instead.

class Index extends Component {
    constructor(props) {
        super(props);
    }
    componentDidMount() {}
    
    render() {
      const tagsAry=[{name:1}]

       return (
           <div>{tagsAry}</div>
       )
}

意思是:未捕获错误:对象作为React子对象无效(找到:具有键{content,key,duration}的对象)。如果要呈现子对象集合,请改用数组。

该问题原因

  • 主要是在render函数里直接渲染一个对象造成的。

解决方案

  • 换成 非对象类型 数据;
  • 直接渲染数据,类似 tagsAry[0].name 或 对象的属性值;

Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.icon-default.png?t=M4ADhttps://serious-lose.notion.site/React-Error-f41e17be772f4f1ea2b1e6c22a723afe

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值