style: remove repeate method (#38133)

* style: remove repeate method

* fix: del break
This commit is contained in:
lijianan 2022-10-20 16:37:35 +08:00 committed by GitHub
parent 7503caeb18
commit 769cb3c79a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -2,7 +2,7 @@ import * as React from 'react';
export const { isValidElement } = React;
export function isFragment(child: React.ReactElement): boolean {
export function isFragment(child: any): boolean {
return child && isValidElement(child) && child.type === React.Fragment;
}

View File

@ -7,7 +7,7 @@ import { ConfigContext } from '../config-provider';
import DisabledContext from '../config-provider/DisabledContext';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import { cloneElement } from '../_util/reactNode';
import { cloneElement, isFragment } from '../_util/reactNode';
import { tuple } from '../_util/type';
import warning from '../_util/warning';
import Wave from '../_util/wave';
@ -24,10 +24,6 @@ function isUnBorderedButtonType(type: ButtonType | undefined) {
return type === 'text' || type === 'link';
}
function isReactFragment(node: React.ReactNode) {
return React.isValidElement(node) && node.type === React.Fragment;
}
// Insert one space between two chinese characters automatically.
function insertSpace(child: React.ReactElement | string | number, needInserted: boolean) {
// Check the child if is undefined or null.
@ -49,7 +45,7 @@ function insertSpace(child: React.ReactElement | string | number, needInserted:
if (typeof child === 'string') {
return isTwoCNChar(child) ? <span>{child.split('').join(SPACE)}</span> : <span>{child}</span>;
}
if (isReactFragment(child)) {
if (isFragment(child)) {
return <span>{child}</span>;
}
return child;