Skip to content

Instantly share code, notes, and snippets.

@peterlazar1993
Created March 17, 2016 17:07
Show Gist options
  • Save peterlazar1993/f40297f7f7585483ce97 to your computer and use it in GitHub Desktop.
Save peterlazar1993/f40297f7f7585483ce97 to your computer and use it in GitHub Desktop.
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