-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathApp.js
47 lines (40 loc) · 1.21 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from "react";
import { createStore } from "redux";
import { Provider } from "react-redux";
import AppNavigator from "./navigator/AppNavigator";
import ApolloClient from "apollo-boost";
import { ApolloProvider } from "react-apollo";
//https://www.contentful.com/developers/docs/javascript/tutorials/using-contentful-graphql-with-javascript/
//https://graphql.contentful.com/content/v1/spaces/{SPACE_ID}/explore?access_token={CDA_TOKEN}
const client = new ApolloClient({
uri: "https://graphql.contentful.com/content/v1/spaces/9p2i4rjrlpxe",
credentials: "same-origin",
headers: {
Authorization: `Bearer AP4JnPGUZBhHLrTap_P1suGxQ1MvvjuNL0WIq0f20mU`,
},
});
const initialState = {
action: "",
name: "",
};
const reducer = (state = initialState, action) => {
switch (action.type) {
case "OPEN_MENU":
return { action: "openMenu" };
case "CLOSE_MENU":
return { action: "closeMenu" };
case "UPDATE_NAME":
return { name: action.name };
default:
return { state };
}
};
const store = createStore(reducer);
const App = () => (
<ApolloProvider client={client}>
<Provider store={store}>
<AppNavigator />
</Provider>
</ApolloProvider>
);
export default App;