Skip to content

Commit

Permalink
feat: feat: Add forwardRef for Badge
Browse files Browse the repository at this point in the history
  • Loading branch information
linhf committed Nov 2, 2023
1 parent 995b66e commit 8ff84da
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/design/src/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ export * from 'antd/es/button';

export type ButtonProps = AntButtonProps;

const Button = ({ prefixCls: customizePrefixCls, className, ...restProps }: ButtonProps) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('btn', customizePrefixCls);
const { wrapSSR } = useStyle(prefixCls);
const buttonCls = classNames(className);
return wrapSSR(<AntButton prefixCls={customizePrefixCls} className={buttonCls} {...restProps} />);
};
const Button = React.forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
({ prefixCls: customizePrefixCls, className, ...restProps }, ref) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('btn', customizePrefixCls);
const { wrapSSR } = useStyle(prefixCls);
const buttonCls = classNames(className);
return wrapSSR(
<AntButton ref={ref} prefixCls={customizePrefixCls} className={buttonCls} {...restProps} />
);
}
);

Button.Group = AntButton.Group;

Check failure on line 24 in packages/design/src/button/index.tsx

View workflow job for this annotation

GitHub Actions / build (16.x, ubuntu-latest)

Property 'Group' does not exist on type 'ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement | HTMLAnchorElement>>'.

Check failure on line 24 in packages/design/src/button/index.tsx

View workflow job for this annotation

GitHub Actions / build (16.x, ubuntu-latest)

Property 'Group' does not exist on type 'ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement | HTMLAnchorElement>>'.
Button.__ANT_BUTTON = (

Check failure on line 25 in packages/design/src/button/index.tsx

View workflow job for this annotation

GitHub Actions / build (16.x, ubuntu-latest)

Property '__ANT_BUTTON' does not exist on type 'ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement | HTMLAnchorElement>>'.

Check failure on line 25 in packages/design/src/button/index.tsx

View workflow job for this annotation

GitHub Actions / build (16.x, ubuntu-latest)

Property '__ANT_BUTTON' does not exist on type 'ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement | HTMLAnchorElement>>'.
Expand Down

0 comments on commit 8ff84da

Please sign in to comment.