Spaces:
Running
Running
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')); |