-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
55 lines (47 loc) · 1.36 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
import { StackNavigator } from 'react-navigation';
import HomeScreen from './src/components/HomeScreen';
import ItemScreen from './src/components/ItemScreen';
import React from 'react';
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import { composeWithDevTools } from 'remote-redux-devtools';
import { persistStore, autoRehydrate } from 'redux-persist';
import { AsyncStorage } from 'react-native';
import {
ApolloClient,
ApolloProvider,
createNetworkInterface,
} from 'react-apollo';
const networkInterface = createNetworkInterface({
uri: 'https://api.graph.cool/simple/v1/cj3m7chxxeiy70177iz0thrdw',
});
const client = new ApolloClient({
networkInterface,
});
import reducers from './src/reducers';
const actualCompose = __DEV__ ? composeWithDevTools : compose;
const store = createStore(
combineReducers({
...reducers,
apollo: client.reducer(),
}),
{},
actualCompose(
applyMiddleware(client.middleware()),
applyMiddleware(thunk),
autoRehydrate()
)
);
persistStore(store, { storage: AsyncStorage });
const App = StackNavigator({
HomeScreen: { screen: HomeScreen },
ItemScreen: { screen: ItemScreen },
});
const AppWithStore = () => {
return (
<ApolloProvider store={store} client={client}>
<App />
</ApolloProvider>
);
};
export default AppWithStore;