Skip to content

Commit

Permalink
fix: 右键菜单项类型问题 (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: yxh01132861 <yxh01132861@antgroup.com>
  • Loading branch information
simplexiao and yxh01132861 authored Sep 21, 2022
1 parent 2d794a1 commit 1019418
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/components/ContextMenu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ nav:

<code src="./demos/custom.tsx"></code>

<API></API>
## API

| 属性名 | 描述 | 类型 | 默认值 |
| --------- | -------- | --------------- | ------ |
| childern | 子组件 | `ReactNode` | -- |
| className | 类名 | `string` | -- |
| style | 行内样式 | `CSSProperties` | -- |

### ContextMenu.Item

Expand Down
8 changes: 6 additions & 2 deletions src/components/ContextMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import type { ContextMenuProps } from './types';
import { ContextMenuItem } from './ContextMenuItem';
import './index.less';

const ContextMenu: React.FC<ContextMenuProps> = (props) => {
export interface ContextMenuPropsType extends React.FC<ContextMenuProps> {
Item?: typeof ContextMenuItem;
}

const ContextMenu: ContextMenuPropsType = (props) => {
const scene = useScene();
const [initMenu, setInitMenu] = useState({
visible: false,
Expand Down Expand Up @@ -62,6 +66,6 @@ const ContextMenu: React.FC<ContextMenuProps> = (props) => {
) : null;
};

(ContextMenu as any).Item = ContextMenuItem;
ContextMenu.Item = ContextMenuItem;

export { ContextMenu };

0 comments on commit 1019418

Please sign in to comment.