-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
63 lines (53 loc) · 1.25 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
import React, { Component } from "react";
import { StyleSheet, View } from "react-native";
import Header from "./src/components/header";
import Game from "./src/components/game";
import { SDE_URL } from "./src/helpers/constants";
export default class App extends Component {
state = {
jogos: {},
isReady: false
};
componentWillMount() {
this.loadJogos();
}
async loadJogos() {
try {
const response = await fetch(`${SDE_URL}/jogos/2/time/Brasil`);
const data = await response.json();
this.setState({ jogos: data, isReady: true });
} catch (error) {
console.log(error);
}
}
render() {
if (!this.state.isReady) {
return <Expo.AppLoading />;
}
const { jogos } = this.state;
return (
<View style={styles.container}>
<Header />
<View style={styles.container__jogos}>
{jogos.map((item, i) => <Game item={item} key={i} />)}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: "column",
justifyContent: "flex-start",
marginTop: 50,
marginLeft: 10,
marginRight: 10
},
container__jogos: {
flex: 2,
alignItems: "center",
marginLeft: 20,
marginRight: 20
}
});