import React from 'react'; import { connect } from 'react-redux'; import { fetchUserProfile } from '../actions'; class User extends React.Component { constructor (props) { super(props) this.state = { isLoading: true } } componentDidMount() { const { user } = this.props.match.params this.props.fetchUserProfile(user) .then(() => this.setState({isLoading: false})) } render () { const {user} = this.props const {isLoading} = this.state if (isLoading) { return

Loading

} else { const currentUser = user.currentUser return (

{currentUser.username}

Email: {currentUser.email}

Location: {currentUser.location}
About Me: {currentUser.bio}
); } } } const mapStateToProps = (state) => { return { user: state.user, }; } export default connect( mapStateToProps, { fetchUserProfile } )(User);