mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 21:18:01 +08:00
919cb22eb7
* Use the prop-types package from npm instead of React.PropTypes * Remove using of PropTypes from React in docs and site
30 lines
832 B
TypeScript
30 lines
832 B
TypeScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
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} />
|
|
);
|
|
}
|
|
}
|