Render with an If/Else Condition1

Tell us what’s happening:

i am not able to understand what is going wrong really

Your code so far

class MyComponent extends React.Component {
  constructor(props) {
    this.state = {
      display: true
    this.toggleDisplay = this.toggleDisplay.bind(this);
  toggleDisplay() {
      display: !this.state.display
  render() {
    // change code below this line
    return (
         <button onClick={this.toggleDisplay}>Toggle Display</button>
      else {
        <button onClick={this.toggleDisplay}>Toggle Display</button>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36.

Link to the challenge:

Two things here.

In your else statement, you don’t need a curly bracket inside return. That means you are returning an object.

Also you need to make sure that you are closing off your div with </div>

1 Like

thanks for your help it worked