sf-d14 / main.js
Samzysi9292's picture
Add 3 files
e77c25d verified
raw
history blame contribute delete
658 Bytes
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'));