import React, {Component} from 'react';
import {FormConsumer} from './FormContext';
import FormItemError from "./FormItemError";
const RadioGroupContext = React.createContext({});
export class RadioGroupConsumer extends Component
{
render()
{
return (
{(props) => this.props.children(props)}
)
}
}
export default class RadioGroup extends Component
{
render()
{
return (
{(data) => this.renderRadioGroup(data)}
)
}
renderRadioGroup(data)
{
return (
{this.renderLabel()}
{this.renderChildren()}
)
}
renderLabel()
{
if (!this.props.label) return null
return (
{this.props.label}
)
}
renderChildren()
{
return (
this.props.onChangeValue(value),
value: this.props.value
}}>
{this.props.children}
)
}
}
RadioGroup.defaultProps = {
name: 'radio',
onChangeValue: (value) => {}
}