Reputation: 236
I am trying to change disable attribute in select on button click in react application using material ui My button code is:
<AsistButton variant="outlined" color="primary" className={classes.button}>X</AsistButton>
and from select is:
<NativeSelect
value={person}
className={classes.margin}
onChange={handleChangeSelect}
input={<BootstrapInput name="person" id="person-customized-native-simple"/>}
disabled
>
<option value=""/>
<option value={10}>Peter</option>
<option value={20}>Alex</option>
<option value={30}>Jon</option>
</NativeSelect>
what function I need to define to achieve that.
Upvotes: 3
Views: 17001
Reputation: 619
you should write a counter in state like:
state={disabled: false}
and the on click should turn this.state.disabled to true.
after that in the NativeSelect component set disabled to
disabled={this.state.disabled}
Upvotes: 5