RPeraltaJr
10/29/2019 - 5:56 PM

Expressions & Conditionals

import React, { Component } from 'react';
import './App.scss';

class App extends Component {

  bar = () => 'Foo';

  render() {
    const name = 'John Doe';
    const foo = () => 'Bar';
    const loading = false;
    const showName = false;

    if(loading) {
      return <h5>Loading...</h5>
    }

    return (
      <div>
        <h1>Hello { name.toUpperCase() }</h1>
        <h2>Hello { 1 + 1 }</h2>
        <h3>Hello { foo() }</h3>
        <h4>Hello { this.bar() }</h4>
        <h5>Hello { showName && name }</h5>
      </div>
    );
  }
}

export default App;