Warning: Each child in a list should have a unique “key” prop
这是因为在渲染 template 模板时缺少 key。
容易忽视的是,
<></> 是Fragment的缩写形式,遍历使用时要加key,而缩写形式是不可以加key的,所以要这样写:
<React.Fragment key={'your key'}>
// ...
</React.Fragment>
Ref:
Objects are not valid as a React child (found: object with keys {xxx}). If you meant to render a collection of children, use an array instead
产生以上错误的原因是,在 jsx 语法中错误的渲染了对象数据,在 react 语法设计里,数组和基本数据类型可以直接插入 jsx 渲染,但是不可以直接插入对象进行渲染。
Ref: