Created
March 17, 2016 17:07
-
-
Save peterlazar1993/6d2f46e469e6bbdd9a15 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, PropTypes } from 'react-native'; | |
import { Actions } from 'react-native-router-flux'; | |
import { connect } from 'react-redux'; | |
import AuthComponent from './components/authComponent'; | |
import { authorizationRequest } from './../../modules/auth/auth'; | |
const mapStateToProps = (state) => { | |
return { | |
user: state.user, | |
isAuthorizing: state.isAuthorizing, | |
}; | |
}; | |
const mapDispatchToProps = (dispatch) => { | |
return { | |
onPressRegister: (credentials) => { | |
dispatch(authorizationRequest(credentials)); | |
}, | |
}; | |
}; | |
class Auth extends Component { | |
componentDidUpdate() { | |
if(this.props.user) { | |
Actions.leaderboard(); | |
} | |
} | |
render() { | |
return ( | |
<AuthComponent isAuthorizing={this.props.isAuthorizing} | |
onPressButton={this.props.onPressRegister} | |
/> | |
); | |
} | |
} | |
Auth.propTypes = { | |
isAuthorizing: PropTypes.bool, | |
onPressRegister: PropTypes.func, | |
user: PropTypes.object, | |
}; | |
export default connect(mapStateToProps, mapDispatchToProps)(Auth); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment