11import * as React from 'react' ;
22import toArray from 'rc-util/lib/Children/toArray' ;
3- import type { MenuItemType , ItemType } from '../interface' ;
3+ import type { ItemType } from '../interface' ;
44import { Divider , MenuItem , MenuItemGroup , SubMenu } from '..' ;
55
66export function parseChildren (
@@ -38,23 +38,23 @@ function convertItemsToNodes(list: ItemType[]) {
3838 return ( list || [ ] )
3939 . map ( ( opt , index ) => {
4040 if ( opt && typeof opt === 'object' ) {
41- const { children, key, type, ...restProps } = opt as any ;
41+ const { label , children, key, type, ...restProps } = opt as any ;
4242 const mergedKey = key ?? `tmp-${ index } ` ;
4343
4444 // MenuItemGroup & SubMenuItem
4545 if ( children || type === 'group' ) {
4646 if ( type === 'group' ) {
4747 // Group
4848 return (
49- < MenuItemGroup key = { mergedKey } { ...restProps } >
49+ < MenuItemGroup key = { mergedKey } { ...restProps } title = { label } >
5050 { convertItemsToNodes ( children ) }
5151 </ MenuItemGroup >
5252 ) ;
5353 }
5454
5555 // Sub Menu
5656 return (
57- < SubMenu key = { mergedKey } { ...restProps } >
57+ < SubMenu key = { mergedKey } { ...restProps } title = { label } >
5858 { convertItemsToNodes ( children ) }
5959 </ SubMenu >
6060 ) ;
@@ -65,10 +65,9 @@ function convertItemsToNodes(list: ItemType[]) {
6565 return < Divider key = { mergedKey } { ...restProps } /> ;
6666 }
6767
68- const { title, ...restMenuItemProps } = restProps as MenuItemType ;
6968 return (
70- < MenuItem key = { mergedKey } { ...restMenuItemProps } >
71- { title }
69+ < MenuItem key = { mergedKey } { ...restProps } >
70+ { label }
7271 </ MenuItem >
7372 ) ;
7473 }
0 commit comments