mh108
8/13/2019 - 7:22 PM

App.js

import React from "react";

// example of conditional rendering

class App extends React.Component {
  constructor() {
    //call the superclass ctor to init the base class part
    super();
    //init the derived class part
    this.state = {
      isLoggedIn: false
    };
  }

  render() {
    //display logic goes in render() before return
    let wordDisplay;
    if (this.state.isLoggedIn) {
      wordDisplay = "in";
    } else {
      wordDisplay = "out";
    }
    return (
      <div>
        <h1>You are currently logged {wordDisplay}</h1>
      </div>
    );
  }
}

export default App;