chore: simplify style requirement

This commit is contained in:
zombiej 2022-02-27 22:17:17 +08:00
parent 912ffb15d0
commit 4aac9f7522
4 changed files with 7 additions and 7 deletions

View File

@ -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 ==================================

View File

@ -154,11 +154,12 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (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>(!!loading);

View File

@ -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

View File

@ -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;