From 4aac9f7522376cfa41cb61818dc774730af5b61e Mon Sep 17 00:00:00 2001 From: zombiej Date: Sun, 27 Feb 2022 22:17:17 +0800 Subject: [PATCH] chore: simplify style requirement --- components/_util/theme/index.tsx | 3 +-- components/button/button.tsx | 5 +++-- components/button/style/index.tsx | 4 ++-- components/config-provider/context.tsx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/_util/theme/index.tsx b/components/_util/theme/index.tsx index 2f89796bf0..551cc2f4c3 100644 --- a/components/_util/theme/index.tsx +++ b/components/_util/theme/index.tsx @@ -86,7 +86,6 @@ export const DesignTokenContext = React.createContext<{ // ================================== Hook ================================== export function useToken() { - const { iconPrefixCls } = React.useContext(ConfigContext); const { token: rootDesignToken, hashed } = React.useContext(DesignTokenContext); const theme = React.useContext(ThemeContext); @@ -95,7 +94,7 @@ export function useToken() { const [token, hashId] = useCacheToken(theme, [defaultDesignToken, rootDesignToken], { salt, }); - return [theme, token, iconPrefixCls, hashed ? hashId : '']; + return [theme, token, hashed ? hashId : '']; } // ================================== Util ================================== diff --git a/components/button/button.tsx b/components/button/button.tsx index d30f738966..ad80d5e8be 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -154,11 +154,12 @@ const InternalButton: React.ForwardRefRenderFunction = (pr ...rest } = props; - const { getPrefixCls, autoInsertSpaceInButton, direction } = React.useContext(ConfigContext); + const { getPrefixCls, autoInsertSpaceInButton, direction, iconPrefixCls } = + React.useContext(ConfigContext); const prefixCls = getPrefixCls('btn', customizePrefixCls); // Style - const wrapSSR = useStyle(prefixCls); + const wrapSSR = useStyle(prefixCls, iconPrefixCls); const size = React.useContext(SizeContext); const [innerLoading, setLoading] = React.useState(!!loading); diff --git a/components/button/style/index.tsx b/components/button/style/index.tsx index 44e02c4766..60ae2befae 100644 --- a/components/button/style/index.tsx +++ b/components/button/style/index.tsx @@ -373,8 +373,8 @@ const genSizeLargeButtonStyle = ( }; // ============================== Export ============================== -export default function useStyle(prefixCls: string) { - const [theme, token, iconPrefixCls, hashId] = useToken(); +export default function useStyle(prefixCls: string, iconPrefixCls: string) { + const [theme, token, hashId] = useToken(); return useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [ // Shared diff --git a/components/config-provider/context.tsx b/components/config-provider/context.tsx index 2da82cf493..0022683778 100644 --- a/components/config-provider/context.tsx +++ b/components/config-provider/context.tsx @@ -25,7 +25,7 @@ export interface ConfigConsumerProps { getTargetContainer?: () => HTMLElement; getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement; rootPrefixCls?: string; - iconPrefixCls?: string; + iconPrefixCls: string; getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string; renderEmpty: RenderEmptyHandler; csp?: CSPConfig;