Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  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;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement