import { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; import { Field } from 'mobx-react-form'; import classnames from 'classnames'; @observer class Radio extends Component { static propTypes = { field: PropTypes.instanceOf(Field).isRequired, className: PropTypes.string, focus: PropTypes.bool, showLabel: PropTypes.bool, }; static defaultProps = { className: null, focus: false, showLabel: true, }; inputElement = null; componentDidMount() { if (this.props.focus) { this.focus(); } } focus() { this.inputElement.focus(); } render() { const { field, className, showLabel } = this.props; return (
{field.label && showLabel && ( )}
{field.options.map(type => ( ))}
{field.error &&
{field.error}
}
); } } export default Radio;