diff --git a/components/cascader/hooks/useColumnIcons.tsx b/components/cascader/hooks/useColumnIcons.tsx index bce3b82a5e..9ae66a3d0f 100644 --- a/components/cascader/hooks/useColumnIcons.tsx +++ b/components/cascader/hooks/useColumnIcons.tsx @@ -3,11 +3,7 @@ import LeftOutlined from '@ant-design/icons/LeftOutlined'; import LoadingOutlined from '@ant-design/icons/LoadingOutlined'; import RightOutlined from '@ant-design/icons/RightOutlined'; -export default function useColumnIcons( - prefixCls: string, - rtl: boolean, - expandIcon?: React.ReactNode, -) { +const useColumnIcons = (prefixCls: string, rtl: boolean, expandIcon?: React.ReactNode) => { let mergedExpandIcon = expandIcon; if (!expandIcon) { mergedExpandIcon = rtl ? : ; @@ -19,5 +15,10 @@ export default function useColumnIcons( ); - return [mergedExpandIcon, loadingIcon]; -} + return React.useMemo>( + () => [mergedExpandIcon, loadingIcon] as const, + [mergedExpandIcon], + ); +}; + +export default useColumnIcons; diff --git a/components/theme/util/genStyleUtils.ts b/components/theme/util/genStyleUtils.ts index 0df9d45b2c..6ce7af0413 100644 --- a/components/theme/util/genStyleUtils.ts +++ b/components/theme/util/genStyleUtils.ts @@ -1,22 +1,14 @@ import { useContext } from 'react'; import { genStyleUtils } from '@ant-design/cssinjs-utils'; +import type { GetCompUnitless } from '@ant-design/cssinjs-utils/es/util/genStyleUtils'; import { ConfigContext } from '../../config-provider/context'; import { genCommonStyle, genLinkStyle } from '../../style'; -import type { - AliasToken, - ComponentTokenMap, - SeedToken, -} from '../interface'; - -import localUseToken, { unitless } from '../useToken'; +import type { AliasToken, ComponentTokenMap, SeedToken } from '../interface'; +import useLocalToken, { unitless } from '../useToken'; import useResetIconStyle from './useResetIconStyle'; -export const { - genStyleHooks, - genComponentStyleHook, - genSubStyleComponent, -} = genStyleUtils< +export const { genStyleHooks, genComponentStyleHook, genSubStyleComponent } = genStyleUtils< ComponentTokenMap, AliasToken, SeedToken @@ -29,18 +21,11 @@ export const { return { rootPrefixCls, iconPrefixCls, - } + }; }, useToken: () => { - const [theme, realToken, hashId, token, cssVar] = localUseToken(); - - return { - theme, - realToken, - hashId, - token, - cssVar, - }; + const [theme, realToken, hashId, token, cssVar] = useLocalToken(); + return { theme, realToken, hashId, token, cssVar }; }, useCSP: () => { const { csp, iconPrefixCls } = useContext(ConfigContext); @@ -50,14 +35,7 @@ export const { return csp ?? {}; }, - getResetStyles: (token) => - [ - { - // Link - '&': genLinkStyle(token), - }, - ] - , + getResetStyles: (token) => [{ '&': genLinkStyle(token) }], getCommonStyle: genCommonStyle, - getCompUnitless: () => unitless as any, -}) + getCompUnitless: (() => unitless) as GetCompUnitless, +});