-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
41 lines (36 loc) · 1013 Bytes
/
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
import React, { Component } from 'react';
import { Platform, StyleSheet, FlatList } from 'react-native';
import Event from './src/components/Event';
type Props = {};
export default class App extends Component<Props> {
constructor() {
super();
this.state = {
events: []
};
}
componentDidMount() {
fetch('https://api.myjson.com/bins/12fzng')
.then(res => res.json())
.then(json => this.setState({ events: json }));
}
render() {
return (
<FlatList
style={styles.container}
keyExtractor={item => item.title}
data={this.state.events}
renderItem={({ item }) =>
<Event event={item} />
}
/>
);
}
}
const statusBar = Platform.OS === 'ios' ? 20 : 0;
const styles = StyleSheet.create({
container: {
marginTop: statusBar,
backgroundColor: 'rgb(11, 11, 11)'
}
});