For some reason, my onClick handlers add an empty request parameter to my URL when I click on them. I was able to fix the problem by adding event.preventDefault to my event handlers, but I would like to better understand what actually happened and if that was the right solution. For context, the code below is a simple component to test some OAuth 2 functions. OnClick handlers simply invoke the reflux action. You will see that I added e.preventDefault () to all of them. Without this fix, at any time when I run one of these functions, my url will change from http: // localhost: 3000 / # / signIn to http: // localhost: 3000 /? # / SignIn . I also use a jet router.
// dependencies ------------------------------------------------------- import React from 'react'; import hello from '../../libs/hello'; import Actions from '../../actions/Actions'; import UserStore from '../../stores/userStore'; var Signin = React.createClass({ // life cycle events -------------------------------------------------- componentDidMount: function () { }, render: function () { return ( <form> <h2>Sign in with Google</h2> <button className="btn btn-primary" onClick={this._signIn} > <i className="fa fa-google" /> <span> Google</span> </button> <button className="btn btn-info" onClick={this._logToken} >Log Token</button> <button className="btn btn-warning" onClick={this._signOut}>Sign Out</button> </form> ); }, // custom methods ----------------------------------------------------- _signIn: function (e) { e.preventDefault(); Actions.signIn(); }, _signOut: function (e) { e.preventDefault(); Actions.signOut(); }, _logToken: function (e) { // e.preventDefault(); Actions.logToken(); } }); export default Signin;
source share