Last active
April 12, 2016 21:03
-
-
Save wordyallen/4ad464c37d3bc632f09da30e485ee7c9 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
//actions.js | |
attemptLogin(){ | |
return (dispatch) =>{ | |
dispatch({type: 'ATTEMPTING_LOGIN'}) //this sets the status on the store through the reducer | |
ref.authWithOAuthPopup("twitter", function(error, authData) { | |
if (error) { | |
console.log("Login Failed!", error); | |
return false | |
} else { | |
return authData | |
} | |
}) | |
} | |
} | |
...................... | |
// loginContainer.js | |
const mapDispatchToProps= (dispatch) => ({attemptLogin(){ | |
dispatch(actions.attemptLogin()) | |
}}) | |
const Login = React.createClass({ | |
contextTypes: { | |
router: React.PropTypes.object.isRequired | |
}, | |
handleSubmit(){ | |
const {attemptLogin} = this.props | |
if(attemptLogin()){ | |
this.context.router.replace('entries') | |
} | |
}, | |
render (){ | |
return( | |
<a className="button is-large is-primary control" onClick={this.handleSubmit}> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment