Skip to content

Instantly share code, notes, and snippets.

@kumarks1122
Created January 15, 2019 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumarks1122/0ff03907769788753b97e9b08cd80ba6 to your computer and use it in GitHub Desktop.
Save kumarks1122/0ff03907769788753b97e9b08cd80ba6 to your computer and use it in GitHub Desktop.
React-Native and Redux Basics - Medium post
import React, { Component } from 'react';
import { View, StyleSheet, Text } from 'react-native';
import { connect } from 'react-redux';
import { UPDATE_USER_DATA } from '../../helpers/actionTypes';
const mapStateToProps = state => ({ ...state.profile });
const mapDispatchToProps = dispatch => ({
submitProfile: payload =>
dispatch({ type: UPDATE_USER_DATA, payload }),
});
class Home extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
const { currentUserName } = this.props;
return (
<View style={styles.container}>
<Text>{currentUserName}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
}
})
export default connect(mapStateToProps, mapDispatchToProps)(Home);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment