Last active
March 12, 2016 06:42
-
-
Save zxqx/de92a703b8a5dcf16fe6 to your computer and use it in GitHub Desktop.
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 { connect } from 'react-redux'; | |
import Header from '../../components/header'; | |
import { attemptUserAuthentication, logoutAndRedirect } from '../../actions/auth'; | |
import { getUserInfo, sendConfirmationEmail } from '../../actions/users'; | |
@connect(state => ({ | |
auth: state.auth, | |
users: state.users | |
})) | |
export default class App extends Component { | |
componentWillMount() { | |
this.props.dispatch(attemptUserAuthentication()); | |
} | |
componentWillReceiveProps() { | |
const { dispatch, auth, users } = this.props; | |
if (auth.isAuthenticated && !users) { | |
dispatch(getUserInfo()); | |
} | |
} | |
render() { | |
const { dispatch, users, children } = this.props; | |
return ( | |
<div className="app"> | |
<Header | |
user={users} | |
onLogout={() => dispatch(logoutAndRedirect())} | |
onResendEmail={() => dispatch(sendConfirmationEmail())} /> | |
{children} | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment