-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreen2.js
66 lines (53 loc) · 1.2 KB
/
Screen2.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
64
65
import React from 'react';
import { connect } from 'react-redux';
import { deletePerson } from './actions';
import {
StyleSheet,
Text,
View
} from 'react-native';
class Screen2 extends React.Component {
static navigationOptions = {
title: 'Screen 2'
};
constructor(props)
{
super(props);
}
render() {
return (
<View style={{flex:1}} >
<View >
{
this.props.peopleList.map((person, index) => (
<View key={index} style={styles.person}>
<Text>Name: {person.name}</Text>
<Text onPress={() => this.props.deletePerson(person)}>Delete Person</Text>
</View>
))
}
</View>
<Text style={{margin:20}}>{this.props.counterValue}</Text>
</View>
)
}
}
const styles = StyleSheet.create({
person: {
marginTop: 12,
},
});
// left-right: variablename for usage : original state value
function mapStateToProps (state) {
return {
peopleList: state.appReducer.people,
counterValue: state.counterReducer.counter
}
}
const mapDispatchToProps = {
deletePerson
};
export default sts= connect(
mapStateToProps,
mapDispatchToProps,
)(Screen2)