Created
December 5, 2017 19:08
-
-
Save kingisaac95/38fed8493741ed7f4fb14986d7841e88 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { Link } from 'react-router'; | |
import { connect } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
import Name from './Name.jsx'; | |
import { fetchUserData } from '../../../actions/getUserActions'; | |
class WorkShop extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
user: {}, | |
name: '', | |
description: '', | |
ingredients: [], | |
procedures: [] | |
}; | |
} | |
getUser(username) { | |
this.props.fetchUserData(username); | |
} | |
render() { | |
const {bio, avatar_url} = this.props.user; | |
const data = { | |
bio, | |
avatar: avatar_url, | |
}; | |
return ( | |
<div> | |
<h1>Welcome to our workshop.</h1> | |
<div> | |
<Link to="/home">Go home!</Link> | |
</div> | |
<div> | |
<button onClick={() => this.getUser('kingisaac95')}>Get user</button> | |
</div> | |
<Name | |
data={data} | |
/> | |
</div> | |
); | |
} | |
} | |
function mapStateToProps(state) { | |
return { | |
user: state.user.userData | |
}; | |
} | |
function mapDispatchToProps(dispatch) { | |
return bindActionCreators({ | |
fetchUserData | |
}, dispatch); | |
} | |
export default connect(mapStateToProps, mapDispatchToProps)(WorkShop); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment