-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
57 lines (50 loc) · 1.31 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
import React from 'react';
import { StackNavigator, TabNavigator } from 'react-navigation';
import ScreenEventList from './components/ScreenEventList';
import ScreenEventDetails from './components/ScreenEventDetails';
import ScreenEventMap from './components/ScreenEventMap';
const EventsScreenNavigator = TabNavigator({
List: {
screen: ScreenEventList,
navigationOptions: {
headerTitle: 'Events',
},
},
Map: {
screen: ScreenEventMap,
navigationOptions: {
headerTitle: 'Events',
},
}
});
const RootNavigator = StackNavigator({
Home: {
screen: EventsScreenNavigator,
},
Details: {
screen: ScreenEventDetails,
navigationOptions: ({navigation}) => ({
title: navigation.state.params.event.title,
})
},
});
class App extends React.Component {
constructor() {
super();
this.state = { upcomingEvents: [], pastEvents: [] };
}
async componentDidMount() {
const response = await fetch(
'https://prideinlondon.org/events?format=json',
);
const json = await response.json();
this.setState({ upcomingEvents: json.upcoming, pastEvents: json.past });
}
render() {
const { upcomingEvents, pastEvents } = this.state;
return (
<RootNavigator screenProps={{upcomingEvents, pastEvents}} />
);
}
}
export default App;