-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
66 lines (57 loc) · 1.45 KB
/
index.ios.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
import React, {
AppRegistry,
Component,
AlertIOS,
View,
Text
} from 'react-native';
import Relay, { DefaultNetworkLayer } from 'react-relay';
import { container } from './src/routes';
import { graphqlURL } from './config';
import moment from "moment";
import { Provider } from 'react-redux';
import store from './src/store';
import Application from './src/app';
import { NetError } from './src/scenes';
import DeviceInfo from "react-native-device-info";
import { SAVE_UNIQUE_ID_AND_DATE } from "./src/actions/actions";
import { EventManager } from './src/event-manager';
Relay.injectNetworkLayer(
new DefaultNetworkLayer(graphqlURL, {
/*fetchTimeout: 30000,
retryDelays: [ 3000, 6000 ],*/
headers: {
'X-Device-Id': DeviceInfo.getUniqueID()
}
})
);
class Mentor extends Component {
constructor (props) {
super(props)
this.state = {
enable: null
}
store.dispatch({
type: SAVE_UNIQUE_ID_AND_DATE,
id: DeviceInfo.getUniqueID(),
appStart: moment()
})
EventManager.on('enable:network', ()=> {
this.setState({
enable: true
})
})
}
render () {
return (
<Provider store={store}>
{container(Application, null, null, (error, retry)=> {
if ( error && (error == 'TypeError: Network request failed') ) {
return <NetError />
}
})}
</Provider>
)
}
}
AppRegistry.registerComponent('Mentor2', () => Mentor);