docs: indicate that menu items require keys (#35474)

This commit is contained in:
Tony Wu 2022-05-11 14:29:26 +08:00 committed by GitHub
parent b4ae9202ed
commit 68a2f8b2ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -29,11 +29,12 @@ ReactDOM.render(<Alert message="After version 4.20.0, we provide a simpler usage
```jsx
// works when >=4.20.0, recommended ✅
const items = [
{ label: 'item 1' },
{ label: 'item 2' },
{ label: 'item 1', key: 'item-1' }, // remember to pass the key prop
{ label: 'item 2', key: 'item-2' }, // which is required
{
label: 'sub menu',
children: [{ label: 'item 3' }],
key: 'submenu'
children: [{ label: 'item 3', key: 'submenu-item-1' }],
},
];
return <Menu items={items} />;

View File

@ -30,11 +30,12 @@ ReactDOM.render(<Alert message="在 4.20.0 版本后,我们提供了 <Menu ite
```jsx
// >=4.20.0 可用,推荐的写法 ✅
const items = [
{ label: '菜单项一' },
{ label: '菜单项二' },
{ label: '菜单项一', key: 'item-1' }, // 菜单项务必填写 key
{ label: '菜单项二', key: 'item-2' },
{
label: '子菜单',
children: [{ label: '子菜单项' }],
key: 'submenu',
children: [{ label: '子菜单项', key: 'submenu-item-1' }],
},
];
return <Menu items={items} />;