fix: Respect user provided space item key (#35344)

This commit is contained in:
Yanlin Jiang 2022-05-05 13:46:52 +08:00 committed by GitHub
parent 6c0f67e407
commit 10596d9604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,15 +88,12 @@ const Space: React.FC<SpaceProps> = props => {
latestIndex = i;
}
const keyOfChild = child && child.key;
// Add `-space-item` as suffix in case simple key string trigger duplicated key warning
// https://github.com/ant-design/ant-design/issues/35305
const defaultKey = `${i}-space-item`;
const key = child && child.key || `${itemClassName}-${i}`;
return (
<Item
className={itemClassName}
key={`${itemClassName}-${keyOfChild || defaultKey}`}
key={key}
direction={direction}
index={i}
marginDirection={marginDirection}