Hi I am stuck with this issue, am just getting started with react js. Its the HOME js component when button is clicked I want to show some text ( when flag is true) else it should show nothing.
import React from 'react';
export default class Home extends React.Component{
constructor(props)
{
super(props);
this.state = {flag: false}
this.showMe = this.showMe.bind(this);
}
showMe()
{
this.state.flag ? ((<div> show this when flag is true </div>) : null)
}
render()
{
return(
<div>
<h1>Welcome to the Tornadoes Website {this.state.flag}</h1>
<button type="button" onClick={this.showMe}>Click me </button>
</div>);
}
}
Error on console:
16:2: Parsing error: Unexpected token, expected ":"
14 | {
15 | this.state.flag ? ((<div> show this when flag is true</div>) : null)
> 16 | }
| ^
17 |
18 |
19 | render()