File size: 658 Bytes
e77c25d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Component, createElement, render } from 'react';
import axios from 'axios';

class App extends Component {
 constructor(props) {
    super(props);
    this.state = {
      data: null
    };
 }

 componentDidMount() {
    axios.get('https://jsonplaceholder.typicode.com/posts').then(response => {
      this.setState({
        data: response.data
      });
    });
 }

 render() {
    if (!this.state.data) {
      return <div>Loading</div>;
    }

    return (
      <div>
        <h1>Food delivery for cambodia</h1>
        <button class="btn btn-green">Order now</button>
      </div>
    );
 }
}

render(<App />, document.querySelector('#root'));