Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserPage extends Component {
- componentWillMount() {
- this.props.dispatch(fetchUser(this.props.user.id));
- }
- render() {
- <UserProfile name={this.props.user.name} />
- }
- }
- const mapStateToProps = (state, ownProps) => {
- return {
- user: _.find(state.users, (user) => user.id == ownProps.params.userId)),
- };
- };
- const mapDispatchToProps = (dispatch) => {
- return {
- dispatch
- };
- };
- export default connect(mapStateToProps, mapDispatchToProps)(UserPage);
- class UserPage extends Component {
- componentWillMount() {
- this.props.dispatch(fetchUser(this.props.user.id));
- }
- renderUser() {
- if (this.props.user) {
- return (
- <UserProfile name={this.props.user.name} />
- )
- }
- }
- render() {
- return (
- <div>{this.renderUser()}</div>
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement