Browse Source

docs: indicate that menu items require `key`s (#35474)

pull/35491/head
Tony Wu 3 years ago
committed by GitHub
parent
commit
68a2f8b2ac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      components/menu/index.en-US.md
  2. 7
      components/menu/index.zh-CN.md

7
components/menu/index.en-US.md

@ -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} />;

7
components/menu/index.zh-CN.md

@ -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} />;

Loading…
Cancel
Save