|
@@ -1,13 +1,59 @@
|
|
1
|
+import React from 'react';
|
1
|
2
|
import { StatusBar } from 'expo-status-bar';
|
2
|
|
-import { StyleSheet, Text, View } from 'react-native';
|
3
|
|
-
|
4
|
|
-export default function App() {
|
5
|
|
- return (
|
6
|
|
- <View style={styles.container}>
|
7
|
|
- <Text>Open up App.js to start working on your app!</Text>
|
8
|
|
- <StatusBar style="auto" />
|
9
|
|
- </View>
|
10
|
|
- );
|
|
3
|
+import { render } from 'react-dom';
|
|
4
|
+import { StyleSheet, Text, View, ActivityIndicator } from 'react-native';
|
|
5
|
+
|
|
6
|
+export default class App extends React.Component {
|
|
7
|
+
|
|
8
|
+ contructor(props) {
|
|
9
|
+ super(props);
|
|
10
|
+
|
|
11
|
+ this.state = {
|
|
12
|
+ isLoading: true,
|
|
13
|
+ dataSource: null,
|
|
14
|
+ }
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ componentDidMount() {
|
|
18
|
+
|
|
19
|
+ return fetch('https://facebook.github.io/react-native/movies.json')
|
|
20
|
+ .then ( (response) => response.json() )
|
|
21
|
+ .then ( (responseJson) => {
|
|
22
|
+
|
|
23
|
+ this.setState({
|
|
24
|
+ isLoading: false,
|
|
25
|
+ dataSource: responseJson.movies,
|
|
26
|
+ })
|
|
27
|
+
|
|
28
|
+ })
|
|
29
|
+
|
|
30
|
+ .catch((error) => {
|
|
31
|
+ console.log(error)
|
|
32
|
+
|
|
33
|
+ });
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ render() {
|
|
37
|
+
|
|
38
|
+ if (this.state.isLoading){
|
|
39
|
+
|
|
40
|
+ return(
|
|
41
|
+ <View style={style.container}>
|
|
42
|
+ <ActivityIndicator />
|
|
43
|
+ </View>
|
|
44
|
+ )
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ else {
|
|
48
|
+
|
|
49
|
+ return (
|
|
50
|
+ <View style={styles.container}>
|
|
51
|
+ <Text>Open up App.js to start working on your app!</Text>
|
|
52
|
+ <StatusBar style="auto" />
|
|
53
|
+ </View>
|
|
54
|
+ );
|
|
55
|
+ }
|
|
56
|
+ }
|
11
|
57
|
}
|
12
|
58
|
|
13
|
59
|
const styles = StyleSheet.create({
|