import React, {Component, PropTypes} from 'react'; import { Text, View, ScrollView, TouchableOpacity, StyleSheet, TextInput } from 'react-native'; import { connect } from 'react-redux'; import * as counterActions from '../reducers/counter/actions'; // this is a traditional React component connected to the redux store class PushedScreen extends Component { static navigatorStyle = { statusBarColor: '#303F9F', toolBarColor: '#3F51B5', navigationBarColor: '#303F9F', buttonsTint: '#FFFFFF', titleColor: '#FFFFFF', tabSelectedTextColor: '#FFA000', tabNormalTextColor: '#FFC107', tabIndicatorColor: '#FF4081' }; static propTypes = { passed: PropTypes.string.isRequired }; constructor(props) { super(props); this.bgColor = this.getRandomColor(); } getRandomColor() { var letters = '0123456789ABCDEF'.split(''); var color = '#'; for (var i = 0; i < 6; i++ ) { color += letters[Math.floor(Math.random() * 16)]; } return color; } render() { return ( Counter: {this.props.counter.count} Increment Counter Push Another Pop Screen Modal Screen Dismiss modal Dismiss all modals {this.props.passed} ); } onIncrementPress() { this.props.dispatch(counterActions.increment()); } onPushPress() { this.props.navigator.push({ title: "More", screen: "example.PushedScreen" }); } onPopPress() { this.props.navigator.pop(); } onShowModalPress() { this.props.navigator.showModal({ title: "Modal Screen", screen: "example.PushedScreen" }); } onDismissAllModalsPress() { this.props.navigator.dismissAllModals(); } onDismissModal() { this.props.navigator.dismissModal(); } } 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)(PushedScreen);