Skip to content

Commit b1be2ab

Browse files
committed
clean: remove cloneElement.
1 parent 0a1e822 commit b1be2ab

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

core/src/components/ToolBar/index.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { Fragment } from 'react';
22
import { ICommand, defaultCommands } from '../../commands';
33
import { IMarkdownEditor, ToolBarProps } from '../..';
44
import './index.less';
@@ -54,16 +54,14 @@ export default function ToolBar(props: IToolBarProps) {
5454
buttonProps[key] = btn[key];
5555
});
5656
} else if (typeof obj.button === 'function') {
57-
return React.cloneElement(
58-
obj.button(obj, editorProps, {
59-
preview,
60-
container,
61-
containerEditor,
62-
editor,
63-
editorProps,
64-
}),
65-
{ key },
66-
);
57+
const CustomButton = obj.button(obj, editorProps, {
58+
preview,
59+
container,
60+
containerEditor,
61+
editor,
62+
editorProps,
63+
});
64+
return <Fragment key={key}>{CustomButton}</Fragment>;
6765
}
6866
return <button {...buttonProps} key={key} />;
6967
})}

0 commit comments

Comments
 (0)