I have a react-bootstrap <Checkbox >
.
It looks like this:
<Checkbox inline onClick={this.handleInclude}> Include </Checkbox>
On some occasions I want the Checkbox to be checked. The api suggests doing the following if you want it checked:
<Checkbox checked inline onClick={this.handleInclude}> Include </Checkbox>
So now I only want to use the checked
keyword during certain states.. so I tried using a ternary statement:
<Checkbox
{this.state.chkbox === true ? "checked" : "" }
inline
onClick={this.handleInclude}>
Include
</Checkbox>
But this throws an Unexpected token
error. How are you supposed to do this with react?
Aucun commentaire:
Enregistrer un commentaire