import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { Radio } from 'antd'
|
|
class MKRadio extends Component {
|
static propTpyes = {
|
config: PropTypes.object,
|
onChange: PropTypes.func
|
}
|
|
state = {
|
defaultValue: this.props.config.initval
|
}
|
|
onChange = (e) => {
|
let value = e.target.value
|
this.props.onChange(value)
|
}
|
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { config } = this.props
|
const { defaultValue } = this.state
|
|
return (
|
<Radio.Group defaultValue={defaultValue} disabled={config.readonly} onChange={this.onChange}>
|
{config.options.map(option => <Radio key={option.key} disabled={option.$disabled} value={option.value}>{option.label}</Radio>)}
|
</Radio.Group>
|
)
|
}
|
}
|
|
export default MKRadio
|