mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:49:57 +08:00
59d38ecea6
* fix: radioButton ref * fix: added radio types test
24 lines
927 B
TypeScript
24 lines
927 B
TypeScript
import * as React from 'react';
|
|
import type { AbstractCheckboxProps } from '../checkbox/Checkbox';
|
|
import { ConfigContext } from '../config-provider';
|
|
import { RadioOptionTypeContextProvider } from './context';
|
|
import type { RadioChangeEvent, RadioRef } from './interface';
|
|
import Radio from './radio';
|
|
|
|
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>;
|
|
|
|
const RadioButton: React.ForwardRefRenderFunction<RadioRef, RadioButtonProps> = (props, ref) => {
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const { prefixCls: customizePrefixCls, ...radioProps } = props;
|
|
const prefixCls = getPrefixCls('radio', customizePrefixCls);
|
|
|
|
return (
|
|
<RadioOptionTypeContextProvider value="button">
|
|
<Radio prefixCls={prefixCls} {...radioProps} type="radio" ref={ref} />
|
|
</RadioOptionTypeContextProvider>
|
|
);
|
|
};
|
|
|
|
export default React.forwardRef<RadioRef, RadioButtonProps>(RadioButton);
|