import React, {Component, PropTypes} from 'react'; import { Text, View, ScrollView, TouchableOpacity, StyleSheet } from 'react-native'; import { connect } from 'react-redux'; import * as counterActions from '../reducers/counter/actions'; import * as appActions from '../reducers/app/actions'; // this is a traditional React component connected to the redux store class LoginScreen extends Component { static propTypes = { str: PropTypes.string.isRequired, obj: PropTypes.object.isRequired, num: PropTypes.number.isRequired }; constructor(props) { super(props); console.log(props); } render() { return ( Counter: {this.props.counter.count} Increment Counter Login String prop: {this.props.str} Number prop: {this.props.num} Object prop: {this.props.obj.str} Array prop: {this.props.obj.arr[0].str} Array of arrays prop: {JSON.stringify(this.props.obj.arr2)} ); } onIncrementPress() { this.props.dispatch(counterActions.increment()); } onLoginPress() { this.props.dispatch(appActions.login()); } } const styles = StyleSheet.create({ text: { textAlign: 'center', fontSize: 18, marginBottom: 10, marginTop:10, }, button: { textAlign: 'center', fontSize: 18, marginBottom: 10, marginTop:10, color: 'blue' } }); // which props do we want to inject, given the global state? function mapStateToProps(state) { return { counter: state.counter }; } export default connect(mapStateToProps)(LoginScreen);