state = {
value: 0,
options: [ 'Не отмечено', 'Отмечено' ],
}
onChange = ({ target: t }) => {
this.setState(() => ({
value: +t[t.dataset.stateAttr],
}));
}
render() {
const { value, options } = this.state;
return (
<div>
<select
value={value}
onChange={this.onChange}
data-state-attr="value"
>
{options.map((n, i) => <option value={i}>{n}</option>)}
</select>
<br />
<label>
<input
type="checkbox"
checked={value}
onChange={this.onChange}
data-state-attr="checked"
/>
{options[value]}
</label>
</div>
);
}