-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用Menu组件的Submenu,绑定了key,控制台报错Duplicated key 'undefined' used in Menu by path [] #33699
Comments
Duplicate of #4853 |
Try |
const RenderMenuItem: React.FC<{ list: DirectoryItem[] }> = ({ list }) => (
<>
{list.map((node: DirectoryItem) => (
<SubMenu
key={node.id}
+ eventKey={node.id}
icon={
<PlusSquareOutlined
onClick={(evt: React.MouseEvent) => {
evt.stopPropagation();
clickPlus(node);
}}
/>
}
title={node.name}
>
</SubMenu>
))}
</>
);
return (
<Menu
defaultOpenKeys={defaultOpenKeys}
defaultSelectedKeys={defaultSelectKeys}
className={styles.menuList}
mode="inline"
style={{ borderRight: 0 }}
>
<RenderMenuItem list={menuData} />
</Menu>
);
}; |
加上eventkey后,控制台会报Each child in a list should have a unique "key" prop.的错误 |
不用函数组件,就不会报错了
|
Thanks, this worked for me! |
Thanks a lot. It worked! |
eventKey current version is not provided anymore, is there any workaround anymore? |
@phuctran2901 did you find a workaround? on v5.0.7 eventKey props exist on Menu.Item but does |
Reproduction link
https://xx.com
Steps to reproduce
What is expected?
submenue的key能成功帮定
What is actually happening?
node.id有值,但是submemu的key是undefined
The text was updated successfully, but these errors were encountered: