SHARE
TWEET

Untitled

a guest Aug 25th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2.  
  3. // example of conditional rendering
  4.  
  5. class App extends React.Component {
  6.   constructor() {
  7.     //call the superclass ctor to init the base class part
  8.     super();
  9.     //init the derived class part
  10.     this.state = {
  11.       isLoggedIn: false
  12.     };
  13.   }
  14.  
  15.   render() {
  16.     //display logic goes in render() before return
  17.     let wordDisplay;
  18.     if (this.state.isLoggedIn) {
  19.       wordDisplay = "in";
  20.     } else {
  21.       wordDisplay = "out";
  22.     }
  23.     return (
  24.       <div>
  25.         <h1>You are currently logged {wordDisplay}</h1>
  26.       </div>
  27.     );
  28.   }
  29. }
  30.  
  31. export default App;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top