diff --git a/.changeset/silent-buckets-grab.md b/.changeset/silent-buckets-grab.md new file mode 100644 index 0000000..94f9e8f --- /dev/null +++ b/.changeset/silent-buckets-grab.md @@ -0,0 +1,5 @@ +--- +'@antv/gpt-vis': patch +--- + +fix: theme undefined with antd@4 diff --git a/src/Text/utils/useAntdDarkAlgorithm.ts b/src/Text/utils/useAntdDarkAlgorithm.ts index 06252e3..f7f258d 100644 --- a/src/Text/utils/useAntdDarkAlgorithm.ts +++ b/src/Text/utils/useAntdDarkAlgorithm.ts @@ -2,10 +2,11 @@ import { ConfigProvider, theme as antdTheme } from 'antd'; import { isArray } from 'lodash'; import { useContext } from 'react'; -const { darkAlgorithm } = antdTheme; - /** 判断是否运用了 antd dark algorithm */ export const useAntdDarkAlgorithm = () => { + // 放到函数内部,避免用户使用 antd@4,theme 变量不存在情况!!! + const darkAlgorithm = antdTheme?.darkAlgorithm; + const config = useContext(ConfigProvider.ConfigContext); const currentAlgorithm = config.theme?.algorithm;