diff --git a/packages/antd/src/__builtins__/hooks/usePrefixCls.ts b/packages/antd/src/__builtins__/hooks/usePrefixCls.ts index ff6074ada3b..d8f07ed4af4 100644 --- a/packages/antd/src/__builtins__/hooks/usePrefixCls.ts +++ b/packages/antd/src/__builtins__/hooks/usePrefixCls.ts @@ -7,6 +7,11 @@ export const usePrefixCls = ( prefixCls?: string } ) => { - const { getPrefixCls } = useContext(ConfigProvider.ConfigContext) - return getPrefixCls(tag, props?.prefixCls) + if ('ConfigContext' in ConfigProvider) { + const { getPrefixCls } = useContext(ConfigProvider.ConfigContext) + return getPrefixCls(tag, props?.prefixCls) + } else { + const prefix = props?.prefixCls ?? 'ant-' + return `${prefix}${tag ?? ''}` + } }