import { Component } from 'react'; import { observer } from 'mobx-react'; import { Field } from 'mobx-react-form'; import classnames from 'classnames'; type Props = { field: typeof Field; className: string; focus: boolean; showLabel: boolean; }; // TODO: Should this file be converted into the coding style similar to './toggle/index.tsx'? class Radio extends Component { static defaultProps = { focus: false, showLabel: true, }; inputElement = null; componentDidMount() { if (this.props.focus) { this.focus(); } } focus() { // @ts-expect-error Object is possibly 'null'. this.inputElement.focus(); } render() { const { field, className, showLabel } = this.props; return (
{field.label && showLabel && ( )}
{field.options.map(type => ( ))}
{field.error &&
{field.error}
}
); } } export default observer(Radio);