Reputation: 1432
In my project, I have a button which I want to disable using state.
<Button
color='success'
onClick={this.changeForm}
block
disabled
>
LOGIN
</Button>
I am using Reactstrap. I have a flag
value set in the state
. I want to disable the button if flag
is set to TRUE
. So, I came up with this code:
<Button
color='success'
onClick={this.changeForm}
block
{this.state.flag && 'disabled'}
>
LOGIN
</Button>
I am getting Syntax Error
. I understand that that's a not proper syntax so how can I achieve the functionality that I want?
Upvotes: 0
Views: 36
Reputation: 969
disabled
is a prop of Button
. Thus:
<Button
color='success'
onClick={this.changeForm}
disabled={this.state.flag}
>
LOGIN
</Button>
Upvotes: 3