I have input text-field and Checkbox, when we click on Checkbox the text-field should get disabled. But I couldn't do that, couldn't able to figure out where i'm going wrong.
I have tried in this way:
<FormControlLabel
control={
<Checkbox
// checked={this.state.games=== -1 ? true : false}
onChange={this.handleTextField}
name="games" color="primary"
/>}
label="all"
/>
}
<TextField required type="number" name='games' variant="outlined"
disabled={this.state.games === -1 ? true : false}
placeholder="value"
onChange={this.handleTextField}
/>
OnChange method:
handleTextField = (e) => {
this.setState({games: e.target.checked === true ? -1 : 0 || e.target.value})
}
Still textfield is not getting disabled. Can anyone help me with this query?