Created
January 8, 2018 22:36
-
-
Save crobinson42/6b55f952550c0ef570d627cf1251ee56 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 { connect } from 'react-redux' | |
| class UserContainer extends Component { | |
| componentDidMount() { | |
| if (!this.props.user) | |
| this.props.getUser() | |
| } | |
| render () { | |
| if (!this.props.user) | |
| return <div>Loading...</div> | |
| return this.props.children | |
| } | |
| } | |
| export default connect( | |
| state => ({ | |
| user: state.user, | |
| }), | |
| { | |
| getUser(), | |
| } | |
| )(UserContainer) |
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 from 'react' | |
| import UserContainer from 'containers/user/UserContainer.jsx' | |
| const UserPage = () => ( | |
| <UserContainer> | |
| This will only show if the user is loaded... | |
| </UserContainer> | |
| ) | |
| export default UserPage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment