diff --git a/components/button/button.tsx b/components/button/button.tsx index ff034502bb..9bc2b2423f 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -177,12 +177,8 @@ const InternalButton: React.ForwardRefRenderFunction = (pr }; // =============== Update Loading =============== - let loadingOrDelay: Loading; - if (typeof loading === 'object' && loading.delay) { - loadingOrDelay = loading.delay || true; - } else { - loadingOrDelay = !!loading; - } + const loadingOrDelay: Loading = + typeof loading === 'object' && loading.delay ? loading.delay || true : !!loading; React.useEffect(() => { clearTimeout(delayTimeoutRef.current); @@ -222,19 +218,9 @@ const InternalButton: React.ForwardRefRenderFunction = (pr const prefixCls = getPrefixCls('btn', customizePrefixCls); const autoInsertSpace = autoInsertSpaceInButton !== false; - // large => lg - // small => sm - let sizeCls = ''; - switch (customizeSize || size) { - case 'large': - sizeCls = 'lg'; - break; - case 'small': - sizeCls = 'sm'; - break; - default: - break; - } + const sizeClassNameMap = { large: 'lg', small: 'sm', middle: undefined }; + const sizeFullname = customizeSize || size; + const sizeCls = sizeFullname ? sizeClassNameMap[sizeFullname] || '' : ''; const iconType = innerLoading ? 'loading' : icon;