JavaScript React Components Stateful Components and Lifecycle Methods Stateful Components and Lifecycle Methods Review

please fill correct answer , isLogIn state ?

class Login extends Component {
  state = { isLoggedIn: false };
  ...
  render() {
    return (
      <button>
        { this.state.isLoggedIn  'Log out'  'Log in' }
      </button>
    );
  }
}

1 Answer

Jackson McComas
Jackson McComas
7,657 Points

The question is looking for ternary operators. The question mark being "if the condition is true then..", and the colon being "If its not true then...."

class Login extends Component {
  state = { isLoggedIn: false };
  ...
  render() {
    return (
      <button>
        { this.state.isLoggedIn ? 'Log out' : 'Log in' }
      </button>
    );
  }
}