ant-design/components/radio/radioButton.tsx
2017-05-08 13:12:34 +08:00

29 lines
811 B
TypeScript

import React, { PropTypes } from 'react';
import { AbstractCheckboxProps } from '../checkbox/Checkbox';
import Radio from './radio';
export interface RadioButtonProps extends AbstractCheckboxProps {}
export default class RadioButton extends React.Component<RadioButtonProps, any> {
static defaultProps = {
prefixCls: 'ant-radio-button',
};
static contextTypes = {
radioGroup: PropTypes.any,
};
render() {
let radioProps: RadioButtonProps = { ...this.props };
if (this.context.radioGroup) {
radioProps.onChange = this.context.radioGroup.onChange;
radioProps.checked = this.props.value === this.context.radioGroup.value;
radioProps.disabled = this.props.disabled || this.context.radioGroup.disabled;
}
return (
<Radio {...radioProps} />
);
}
}