Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement