-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
78 lines (66 loc) · 1.8 KB
/
App.js
File metadata and controls
78 lines (66 loc) · 1.8 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react';
import { connect } from "react-redux";
import {
StyleSheet,
View,
} from 'react-native';
import PlaceList from './src/components/PlaceList';
import PlaceInput from './src/components/PlaceInput';
import placeImage from './src/assets/cat.jpg';
import PlaceDetail from './src/components/PlaceDetail';
import {
addPlace,
deletePlace,
selectPlace,
deselectPlace
} from './src/store/actions';
class App extends React.Component {
placeSelectedHandler = (key) => {
this.props.onSelectPlace(key);
}
placeAddedHandler = (placeName) => {
this.props.onAddPlace(placeName)
};
placeDeleteHandler = () => {
this.props.onDeletePlace()
};
modalClosedHandler = () => {
this.props.onDeselectPlace();
}
render() {
return (
<View style={styles.container}>
<PlaceDetail
selectedPlace={this.props.selectedPlace}
onItemDeleted={this.placeDeleteHandler}
onModalClosed={this.modalClosedHandler}
/>
<PlaceInput onPlaceAdded={this.placeAddedHandler}/>
<PlaceList places={this.props.places} onItemSelected={this.placeSelectedHandler }/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 26,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'flex-start',
},
});
const mapStateToProps = (state) => {
console.log(state);
return {
places: state.places.places,
selectedPlace: state.places.selectedPlace
}
};
const mapDispatchToProps = (dispatch) => ({
onAddPlace: (name) => dispatch(addPlace(name)),
onDeletePlace: () => dispatch(deletePlace()),
onSelectPlace: (key) => dispatch(selectPlace(key)),
onDeselectPlace: () => dispatch(deselectPlace())
});
export default connect(mapStateToProps, mapDispatchToProps)(App)