Skip to content

Instantly share code, notes, and snippets.

@SathinduGA
Last active September 10, 2018 15:09
Show Gist options
  • Save SathinduGA/824077ca361d2330b2c66ba4720ac2e7 to your computer and use it in GitHub Desktop.
Save SathinduGA/824077ca361d2330b2c66ba4720ac2e7 to your computer and use it in GitHub Desktop.
Main Screen
import React, { Component } from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { connect } from 'react-redux';
import { counterAdd, counterSubtract } from '../store/actions/index';
import CounterComponent from '../components/counter';
class MainScreen extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
return (
<View style={styles.mainContainer}>
<CounterComponent />
<View style={styles.buttonContainer}>
<TouchableOpacity onPress={() => this.props.counterAddFunction()}><Text>INCREASE</Text></TouchableOpacity>
<TouchableOpacity onPress={() => this.props.counterSubtractFunction()}><Text>DECREASE</Text></TouchableOpacity>
</View>
</View>
);
}
}
const mapStateToProps = state => {
return {
};
};
const mapDispatchToProps = dispatch => {
return {
counterAddFunction: () => dispatch(counterAdd()),
counterSubtractFunction: () => dispatch(counterSubtract()),
};
};
export default connect(mapStateToProps, mapDispatchToProps)(MainScreen);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment