Created
January 15, 2019 18:41
-
-
Save kumarks1122/e5ed98dd6fb003955cb0e1c749a62c75 to your computer and use it in GitHub Desktop.
React-Native and Redux Basics - Medium post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Platform, 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 Profile extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; | |
} | |
componentDidMount() { | |
this.props.submitProfile("Meis") | |
} | |
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)(Profile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment