-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
52 lines (42 loc) · 1.15 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
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { AppLoading, Asset } from 'expo';
import Navigation from './navigation';
import { Block } from './components';
// import all used images
const images = [
require('./assets/images/img1.png'),
require('./assets/images/img2.png'),
require('./assets/images/img3.png'),
];
export default class App extends React.Component {
state = {
isLoadingComplete: false,
}
handleResourcesAsync = async () => {
// we're caching all the images
// for better performance on the app
const cacheImages = images.map(image => {
return Asset.fromModule(image).downloadAsync();
});
return Promise.all(cacheImages);
}
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this.handleResourcesAsync}
onError={error => console.warn(error)}
onFinish={() => this.setState({ isLoadingComplete: true })}
/>
)
}
return (
<Block white>
<Navigation />
</Block>
);
}
}
const styles = StyleSheet.create({
});