From 46239d15dca4ccda8f9c35826831c121988e53ec Mon Sep 17 00:00:00 2001 From: dengfuping Date: Wed, 18 Oct 2023 12:04:15 +0800 Subject: [PATCH] fix(design): hashId should be "" when hashed is false --- packages/design/src/_util/genComponentStyleHook.ts | 7 ++++++- .../src/badge/__tests__/__snapshots__/index.test.tsx.snap | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/design/src/_util/genComponentStyleHook.ts b/packages/design/src/_util/genComponentStyleHook.ts index e7af8008b..c629522ff 100644 --- a/packages/design/src/_util/genComponentStyleHook.ts +++ b/packages/design/src/_util/genComponentStyleHook.ts @@ -4,6 +4,8 @@ import type { FullToken, GenerateStyle } from 'antd/es/theme/internal'; import { genComponentStyleHook as antGenComponentStyleHook } from 'antd/es/theme/internal'; import type { GlobalToken } from 'antd/es/theme/interface'; import type { OverrideTokenWithoutDerivative } from 'antd/es/theme/util/genComponentStyleHook'; +import { useContext } from 'react'; +import theme from '../theme'; export type ComponentName = keyof ComponentTokenMap; @@ -22,7 +24,10 @@ export function genComponentStyleHook( }, getDefaultToken ); - const [wrapSSR, hashId] = useStyle(prefixCls); + const [wrapSSR] = useStyle(prefixCls); + // use hashId from useToken, as hashId is '' when hashed is false + // ref: https://github.com/ant-design/ant-design/blob/master/components/theme/useToken.ts#L80 + const { hashId } = theme.useToken(); return { wrapSSR, hashId, diff --git a/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap b/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap index 7316ff7ef..6cf09b5a1 100644 --- a/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap @@ -2,7 +2,7 @@ exports[`Badge status custom icon 1`] = `