mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
afa4442a10
* refactor: add optionType for Radio internally * fix: lint * fix: update snapshot * feat: remove useless condition for RadioGroupContext * test: add test case for Radio.Button
24 lines
853 B
TypeScript
24 lines
853 B
TypeScript
import * as React from 'react';
|
|
import Radio from './radio';
|
|
import { RadioChangeEvent } from './interface';
|
|
import { AbstractCheckboxProps } from '../checkbox/Checkbox';
|
|
import { ConfigContext } from '../config-provider';
|
|
import { RadioOptionTypeContextProvider } from './context';
|
|
|
|
export type RadioButtonProps = AbstractCheckboxProps<RadioChangeEvent>;
|
|
|
|
const RadioButton = (props: RadioButtonProps, ref: React.Ref<any>) => {
|
|
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(RadioButton);
|