forked from benmvp/react-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
32 lines (27 loc) · 810 Bytes
/
App.js
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
import React from 'react';
import 'whatwg-fetch';
import EmailList from '../components/EmailList';
import EmailView from '../components/EmailView';
import EmailForm from '../components/EmailForm';
export default class EmailApp extends React.Component {
state = {
emails: []
}
componentDidMount() {
// Retrieve emails from server once we know DOM exists
fetch('http://localhost:9090/emails')
.then((res) => res.json())
.then((emails) => this.setState({emails}))
.catch((ex) => console.error(ex));
}
render() {
let {emails} = this.state;
return (
<main>
<EmailList emails={emails} />
<EmailView />
<EmailForm />
</main>
);
}
}