1
1
import * as React from 'react' ;
2
2
import toArray from 'rc-util/lib/Children/toArray' ;
3
- import type { MenuItemType , ItemType } from '../interface' ;
3
+ import type { ItemType } from '../interface' ;
4
4
import { Divider , MenuItem , MenuItemGroup , SubMenu } from '..' ;
5
5
6
6
export function parseChildren (
@@ -38,23 +38,23 @@ function convertItemsToNodes(list: ItemType[]) {
38
38
return ( list || [ ] )
39
39
. map ( ( opt , index ) => {
40
40
if ( opt && typeof opt === 'object' ) {
41
- const { children, key, type, ...restProps } = opt as any ;
41
+ const { label , children, key, type, ...restProps } = opt as any ;
42
42
const mergedKey = key ?? `tmp-${ index } ` ;
43
43
44
44
// MenuItemGroup & SubMenuItem
45
45
if ( children || type === 'group' ) {
46
46
if ( type === 'group' ) {
47
47
// Group
48
48
return (
49
- < MenuItemGroup key = { mergedKey } { ...restProps } >
49
+ < MenuItemGroup key = { mergedKey } { ...restProps } title = { label } >
50
50
{ convertItemsToNodes ( children ) }
51
51
</ MenuItemGroup >
52
52
) ;
53
53
}
54
54
55
55
// Sub Menu
56
56
return (
57
- < SubMenu key = { mergedKey } { ...restProps } >
57
+ < SubMenu key = { mergedKey } { ...restProps } title = { label } >
58
58
{ convertItemsToNodes ( children ) }
59
59
</ SubMenu >
60
60
) ;
@@ -65,10 +65,9 @@ function convertItemsToNodes(list: ItemType[]) {
65
65
return < Divider key = { mergedKey } { ...restProps } /> ;
66
66
}
67
67
68
- const { title, ...restMenuItemProps } = restProps as MenuItemType ;
69
68
return (
70
- < MenuItem key = { mergedKey } { ...restMenuItemProps } >
71
- { title }
69
+ < MenuItem key = { mergedKey } { ...restProps } >
70
+ { label }
72
71
</ MenuItem >
73
72
) ;
74
73
}
0 commit comments