Browse Source

chore: Use cssinjs `createTheme` which support auto cache (#36329)

* chore: bump

* chore: use cssinjs cache version
pull/36381/head
二货机器人 2 years ago
committed by GitHub
parent
commit
bd2b80fb88
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      components/config-provider/index.tsx
  2. 6
      components/theme/index.tsx
  3. 2
      package.json

4
components/config-provider/index.tsx

@ -1,4 +1,4 @@
import { Theme as V5Theme } from '@ant-design/cssinjs';
import { createTheme } from '@ant-design/cssinjs';
import IconContext from '@ant-design/icons/lib/components/Context';
import { FormProvider as RcFormProvider } from 'rc-field-form';
import type { ValidateMessages } from 'rc-field-form/lib/interface';
@ -251,7 +251,7 @@ const ProviderChildren: React.FC<ProviderChildrenProps> = props => {
// ================================ Dynamic theme ================================
const memoTheme = React.useMemo(() => {
const { algorithm, token, ...rest } = mergedTheme || {};
const themeObj = algorithm ? new V5Theme(algorithm) : undefined;
const themeObj = algorithm ? createTheme(algorithm) : undefined;
return {
...rest,

6
components/theme/index.tsx

@ -1,5 +1,5 @@
import type { CSSInterpolation } from '@ant-design/cssinjs';
import { Theme, useCacheToken, useStyleRegister } from '@ant-design/cssinjs';
import type { CSSInterpolation, Theme } from '@ant-design/cssinjs';
import { createTheme, useCacheToken, useStyleRegister } from '@ant-design/cssinjs';
import React from 'react';
import version from '../version';
import type {
@ -20,7 +20,7 @@ import genComponentStyleHook from './util/genComponentStyleHook';
import getArrowStyle from './util/placementArrow';
import statisticToken, { merge as mergeToken, statistic } from './util/statistic';
const defaultTheme = new Theme(defaultDerivative);
const defaultTheme = createTheme(defaultDerivative);
export {
resetComponent,

2
package.json

@ -115,7 +115,7 @@
],
"dependencies": {
"@ant-design/colors": "^6.0.0",
"@ant-design/cssinjs": "^0.0.0-alpha.34",
"@ant-design/cssinjs": "^0.0.0-alpha.35",
"@ant-design/icons": "^4.7.0",
"@ant-design/react-slick": "~0.29.1",
"@babel/runtime": "^7.18.3",

Loading…
Cancel
Save