ant-design/components/radio/radioButton.tsx

25 lines
971 B
TypeScript
Raw Normal View History

import * as React from 'react';
import type { CheckboxRef } from '../checkbox';
import type { AbstractCheckboxProps } from '../checkbox/Checkbox';
import { ConfigContext } from '../config-provider';
import { RadioOptionTypeContextProvider } from './context';
2022-06-22 14:57:09 +08:00
import type { RadioChangeEvent } from './interface';
import Radio from './radio';
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>;
2016-08-10 10:26:42 +08:00
const RadioButton: React.ForwardRefRenderFunction<CheckboxRef, 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>
);
};
2018-11-09 17:38:19 +08:00
export default React.forwardRef<CheckboxRef, RadioButtonProps>(RadioButton);