docs: update Extends Theme docs (#53507)

This commit is contained in:
lijianan 2025-04-15 16:50:15 +08:00 committed by GitHub
parent 973df96f1a
commit 84fea6366e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -78,7 +78,7 @@ const useButtonStyle = createStyles(({ css }, prefixCls: string) => {
});
const GeekProvider: React.FC<Readonly<React.PropsWithChildren>> = (props) => {
const { getPrefixCls } = React.use(ConfigProvider.ConfigContext);
const { getPrefixCls } = React.useContext(ConfigProvider.ConfigContext);
const btnPrefixCls = getPrefixCls('btn');
const { styles } = useButtonStyle(btnPrefixCls);
return <ConfigProvider button={{ className: styles.btn }}>{props.children}</ConfigProvider>;
@ -94,10 +94,12 @@ It's also easy to extend for scenarios that need to inherit `className`:
```tsx
import React from 'react';
import { ConfigProvider } from 'antd';
import classNames from 'classnames';
const GeekProvider: React.FC<Readonly<React.PropsWithChildren>> = (props) => {
const { button } = React.useContext(ConfigProvider.ConfigContext);
const { styles } = useButtonStyle();
const { button, getPrefixCls } = React.useContext(ConfigProvider.ConfigContext);
const btnPrefixCls = getPrefixCls('btn');
const { styles } = useButtonStyle(btnPrefixCls);
return (
<ConfigProvider button={{ className: classNames(button?.className, styles.btn) }}>
{props.children}

View File

@ -78,7 +78,7 @@ const useButtonStyle = createStyles(({ css }, prefixCls: string) => {
});
const GeekProvider: React.FC<Readonly<React.PropsWithChildren>> = (props) => {
const { getPrefixCls } = React.use(ConfigProvider.ConfigContext);
const { getPrefixCls } = React.useContext(ConfigProvider.ConfigContext);
const btnPrefixCls = getPrefixCls('btn');
const { styles } = useButtonStyle(btnPrefixCls);
return <ConfigProvider button={{ className: styles.btn }}>{props.children}</ConfigProvider>;
@ -94,10 +94,12 @@ export default GeekProvider;
```tsx
import React from 'react';
import { ConfigProvider } from 'antd';
import classNames from 'classnames';
const GeekProvider: React.FC<Readonly<React.PropsWithChildren>> = (props) => {
const { button } = React.useContext(ConfigProvider.ConfigContext);
const { styles } = useButtonStyle();
const { button, getPrefixCls } = React.useContext(ConfigProvider.ConfigContext);
const btnPrefixCls = getPrefixCls('btn');
const { styles } = useButtonStyle(btnPrefixCls);
return (
<ConfigProvider button={{ className: classNames(button?.className, styles.btn) }}>
{props.children}