fix: detect antd button by children.type.[staticProperty] instead of same class for HOC case (#19042)

This commit is contained in:
绯一 2019-09-28 10:20:47 +08:00 committed by 只捱宅
parent b536643f76
commit 049799ed0f

View File

@ -92,7 +92,10 @@ export default class Search extends React.Component<SearchProps, any> {
let button: React.ReactNode;
const enterButtonAsElement = enterButton as React.ReactElement<any>;
if (enterButtonAsElement.type === Button || enterButtonAsElement.type === 'button') {
const isAntdButton =
enterButtonAsElement.type &&
(enterButtonAsElement.type as typeof Button).__ANT_BUTTON === true;
if (isAntdButton || enterButtonAsElement.type === 'button') {
button = React.cloneElement(enterButtonAsElement, {
onClick: this.onSearch,
key: 'enterButton',