-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
104 lines (93 loc) · 3 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// @flow
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import { applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import axios from 'axios';
import axiosMiddleware from 'redux-axios-middleware';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import Reactotron from './src/tools/ReactotronConfig';
import { API_BASE_URL } from './src/constants/api';
import reducer from './src/reducers/index';
import ListPlayers from './src/components/ListPlayers';
import ListGames from './src/components/ListGames';
import HomeScreen from './src/components/HomeScreen';
import EditGame from './src/components/EditGame';
import ShowGame from './src/components/ShowGame';
import ListTeams from './src/components/ListTeams';
import ShowTeam from './src/components/ShowTeam';
import ShowPlayer from './src/components/ShowPlayer';
// eslint-disable-next-line no-undef
if (__DEV__) {
// eslint-disable-next-line global-require
// const MessageQueue = require('react-native/Libraries/BatchedBridge/MessageQueue.js');
// const spyFunction = (msg: any) => {
// // eslint-disable-next-line no-console
// console.log(msg);
// };
//
// MessageQueue.spy(spyFunction);
// eslint-disable-next-line no-console
import('./src/tools/ReactotronConfig').then(() => console.log('Reactotron Configured'));
}
const client = axios.create({
baseURL: API_BASE_URL,
responseType: 'json',
// access to fetch requests on aws blocked
// https://stackoverflow.com/questions/53203024/access-to-fetch-at-aws-lambda-site-from-origin-http-localhost3000-has-been
headers: {
'access-control-allow-origin': 'localhost',
'access-control-allow-credentials': 'true',
},
});
const store = Reactotron.createStore(reducer, applyMiddleware(axiosMiddleware(client)));
const AppNavigator = createStackNavigator(
{
Home: HomeScreen,
Players: ListPlayers,
Games: ListGames,
Teams: ListTeams,
EditGame,
ShowGame,
ShowPlayer,
ShowTeam,
},
{
initialRouteName: 'Home',
defaultNavigationOptions: {
// headerMode: 'none',
},
// headerMode: 'none',
},
);
const AppContainer = createAppContainer(AppNavigator);
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
marginTop: 50,
},
});
export default class App extends Component<*> {
// eslint-disable-next-line react/sort-comp
navigator: ?typeof AppContainer;
handleNavigationChange = (prevState: Object, newState: Object, action: string) => {
// eslint-disable-next-line no-console
console.log('handleNavigationChange', prevState, newState, action);
};
render() {
return (
<Provider store={store}>
<View style={styles.container}>
<AppContainer
onNavigationStateChange={this.handleNavigationChange}
uriPrefix="/app"
ref={(nav: ?AppContainer) => {
this.navigator = nav;
}}
/>
</View>
</Provider>
);
}
}