This repository has been archived by the owner on Feb 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathApp.js
82 lines (73 loc) · 2.09 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React from "react";
import { View, Text } from "react-native";
import ApolloClient, { createNetworkInterface } from "apollo-client";
import { ApolloProvider } from "react-apollo";
import { Font } from "expo";
import { compose, createStore, combineReducers, applyMiddleware } from "redux";
import { offline } from "redux-offline";
import config from "redux-offline/lib/defaults";
import Rehydrate from "./Rehydrate";
import { component as Root } from "./lib/js/re/root";
console.ignoredYellowBox = [
"Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead."
];
const networkInterface = createNetworkInterface({
uri: `https://api.graph.cool/simple/v1/cj5cm0t4pnljk01087tv4g61a`
});
const client = new ApolloClient({
networkInterface
});
const store = createStore(
combineReducers({
apollo: client.reducer(),
rehydrate: (state = false, action) => {
switch (action.type) {
case "REHYDRATE_STORE":
return true;
default:
return state;
}
}
}),
undefined,
compose(
applyMiddleware(client.middleware()),
offline({
...config,
persistCallback: () => {
store.dispatch({ type: "REHYDRATE_STORE" });
},
persistOptions: {
blacklist: ["rehydrate"]
}
})
)
);
export default class App extends React.Component {
state = {
fontLoaded: false
};
async componentDidMount() {
await Font.loadAsync({
"open-sans": require("./static/OpenSans-Regular.ttf"),
"open-sans-bold": require("./static/OpenSans-Bold.ttf"),
montserrat: require("./static/Montserrat-Regular.ttf"),
"montserrat-bold": require("./static/Montserrat-Bold.ttf")
});
this.setState({
fontLoaded: true
});
}
render() {
return (
<View style={{ flex: 1, backgroundColor: "rgb(54, 97, 115)" }}>
<ApolloProvider client={client} store={store}>
<Rehydrate>
{this.state.fontLoaded ? <Root /> : null}
</Rehydrate>
</ApolloProvider>
</View>
);
return;
}
}