Skip to content

Commit

Permalink
type(menu): use React.isValidElement replace any (#43989)
Browse files Browse the repository at this point in the history
* type(menu): use React.isValidElement replace any

* fix
  • Loading branch information
thinkasany committed Aug 3, 2023
1 parent 4476c90 commit bbe1ea8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import omit from 'rc-util/lib/omit';
import * as React from 'react';
import { forwardRef } from 'react';
import initCollapseMotion from '../_util/motion';
import { cloneElement } from '../_util/reactNode';
import { cloneElement, isValidElement } from '../_util/reactNode';
import warning from '../_util/warning';
import { ConfigContext } from '../config-provider';
import type { SiderContextProps } from '../layout/Sider';
Expand Down Expand Up @@ -123,13 +123,16 @@ const InternalMenu = forwardRef<RcMenuRef, InternalMenuProps>((props, ref) => {
const menuClassName = classNames(`${prefixCls}-${theme}`, menu?.className, className);

// ====================== Expand Icon ========================
let mergedExpandIcon: MenuProps[`expandIcon`];
let mergedExpandIcon: MenuProps['expandIcon'];
if (typeof expandIcon === 'function') {
mergedExpandIcon = expandIcon;
} else {
const beClone: any = expandIcon || overrideObj.expandIcon;
const beClone: React.ReactNode = expandIcon || overrideObj.expandIcon;
mergedExpandIcon = cloneElement(beClone, {
className: classNames(`${prefixCls}-submenu-expand-icon`, beClone?.props?.className),
className: classNames(
`${prefixCls}-submenu-expand-icon`,
isValidElement(beClone) ? beClone.props?.className : '',
),
});
}

Expand Down

0 comments on commit bbe1ea8

Please sign in to comment.