react 报
Uncaught Error: Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array …
今天碰到了一个react报这个错误的;查找了一下 原来是因为在render的时候 没有点上对象的key名字,
比如:` <div className="y-axias">
{((item: string, index: number) => (
<div className="item" title={item} key={index}>
{item}
</div>
))}
</div>`
里面有个项,是对象(‘{}’);item没有点上对象的key
可以写成` <div className="y-axias">
{((item: string, index: number) => (
<div className="item" title={item} key={index}>
{item || item[对象的key]}
</div>
))}
</div>`