Skip to content

Commit

Permalink
fix: theme undefined with antd@4
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Dec 6, 2024
1 parent 70a7ac0 commit 817a818
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Text/utils/useAntdDarkAlgorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 817a818

Please sign in to comment.