import React, { useMemo, useState } from 'react'; import { Button, ColorPicker, theme } from 'antd'; import type { Color } from 'antd/es/color-picker'; const Demo: React.FC = () => { const { token } = theme.useToken(); const [color, setColor] = useState(token.colorPrimary); const bgColor = useMemo( () => (typeof color === 'string' ? color : color.toHexString()), [color], ); const btnStyle: React.CSSProperties = { backgroundColor: bgColor, }; return ( ); }; export default Demo;