diff --git a/lecture5/email-client-context/app/contexts/EmailsContext.js b/lecture5/email-client-context/app/contexts/EmailsContext.js
deleted file mode 100644
index 744c935..0000000
--- a/lecture5/email-client-context/app/contexts/EmailsContext.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import React from 'react';
-
-const { Provider, Consumer } = React.createContext();
-
-export { Provider as EmailsProvider, Consumer as EmailsConsumer };
diff --git a/lecture5/email-client-context/app/contexts/EmailsContext.jsx b/lecture5/email-client-context/app/contexts/EmailsContext.jsx
new file mode 100644
index 0000000..4b25e1f
--- /dev/null
+++ b/lecture5/email-client-context/app/contexts/EmailsContext.jsx
@@ -0,0 +1,35 @@
+import React from 'react';
+
+import { fetchEmails } from '../actions';
+
+const { Provider, Consumer } = React.createContext();
+
+class EmailsProvider extends React.Component {
+ state = {
+ emails: [],
+ };
+
+ fetchEmails = async () => {
+ const { emails } = await fetchEmails();
+
+ return this.setState(state => ({
+ emails: [...state.emails, ...emails],
+ }));
+ };
+
+ render() {
+ return (
+
+ {this.props.children}
+
+ );
+ }
+}
+
+export { EmailsProvider, Consumer as EmailsConsumer };
diff --git a/lecture5/email-client-context/app/index.jsx b/lecture5/email-client-context/app/index.jsx
index c6611a7..bd3811c 100644
--- a/lecture5/email-client-context/app/index.jsx
+++ b/lecture5/email-client-context/app/index.jsx
@@ -9,21 +9,20 @@ import { login, fetchEmails } from './actions';
class App extends React.Component {
state = {
user: undefined,
- emails: [],
};
updateUser = user => this.setState({ user });
- fetchEmails = async () => {
+ /*fetchEmails = async () => {
const { emails } = await fetchEmails();
return this.setState(state => ({
emails: [...state.emails, ...emails],
}));
- };
+ };*/
render() {
- const { user, emails } = this.state;
+ const { user } = this.state;
return (
@@ -37,15 +36,7 @@ class App extends React.Component {
state: { user },
actions: {},
}}>
-
+