mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 12:09:14 +08:00
refactor: Input.Group use context hook (#34361)
This commit is contained in:
parent
8fe8df777e
commit
33ddc539df
@ -1,6 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import { useContext } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||
import { ConfigContext } from '../config-provider';
|
||||
|
||||
export interface GroupProps {
|
||||
className?: string;
|
||||
@ -15,9 +16,8 @@ export interface GroupProps {
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
const Group: React.FC<GroupProps> = props => (
|
||||
<ConfigConsumer>
|
||||
{({ getPrefixCls, direction }: ConfigConsumerProps) => {
|
||||
const Group: React.FC<GroupProps> = props => {
|
||||
const { getPrefixCls, direction } = useContext(ConfigContext);
|
||||
const { prefixCls: customizePrefixCls, className = '' } = props;
|
||||
const prefixCls = getPrefixCls('input-group', customizePrefixCls);
|
||||
const cls = classNames(
|
||||
@ -30,6 +30,7 @@ const Group: React.FC<GroupProps> = props => (
|
||||
},
|
||||
className,
|
||||
);
|
||||
|
||||
return (
|
||||
<span
|
||||
className={cls}
|
||||
@ -42,8 +43,6 @@ const Group: React.FC<GroupProps> = props => (
|
||||
{props.children}
|
||||
</span>
|
||||
);
|
||||
}}
|
||||
</ConfigConsumer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Group;
|
||||
|
Loading…
Reference in New Issue
Block a user