Created
January 15, 2019 18:39
-
-
Save kumarks1122/0ff03907769788753b97e9b08cd80ba6 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 { 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