{"action":"opened","issue":{"url":"https://api.github.com/repos/ReactjsProgram/React-Fundamentals/issues/19","repository_url":"https://api.github.com/repos/ReactjsProgram/React-Fundamentals","labels_url":"https://api.github.com/repos/ReactjsProgram/React-Fundamentals/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/ReactjsProgram/React-Fundamentals/issues/19/comments","events_url":"https://api.github.com/repos/ReactjsProgram/React-Fundamentals/issues/19/events","html_url":"https://github.com/ReactjsProgram/React-Fundamentals/issues/19","id":160171173,"number":19,"title":"Caching Player Two username","user":{"login":"hagary","id":13905248,"avatar_url":"https://avatars.githubusercontent.com/u/13905248?v=3","gravatar_id":"","url":"https://api.github.com/users/hagary","html_url":"https://github.com/hagary","followers_url":"https://api.github.com/users/hagary/followers","following_url":"https://api.github.com/users/hagary/following{/other_user}","gists_url":"https://api.github.com/users/hagary/gists{/gist_id}","starred_url":"https://api.github.com/users/hagary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hagary/subscriptions","organizations_url":"https://api.github.com/users/hagary/orgs","repos_url":"https://api.github.com/users/hagary/repos","events_url":"https://api.github.com/users/hagary/events{/privacy}","received_events_url":"https://api.github.com/users/hagary/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-14T12:40:16Z","updated_at":"2016-06-14T12:40:16Z","closed_at":null,"body":"In **PromptContainer.js**, the **handleSubmitUser** function, the current username is cached yet never used.\r\nThe state's username is reset, so in the query's playerTwo field, the cached username should be used instead of the state's one.\r\nThis still works since setState is asynchronous and by pure luck, it hasn't got reset yet when we use this.state.username. \r\n\r\nThe correct code should be:\r\n`  handleSubmitUser  : function(e){\r\n    e.preventDefault();\r\n    var username  = this.state.username;\r\n    this.setState({\r\n      username: ''\r\n    })\r\n\r\n    if(this.props.routeParams.playerOne){\r\n      this.context.router.push({\r\n        pathname: '/battle',\r\n        query:{\r\n          playerOne: this.props.routeParams.playerOne,\r\n          playerTwo: username //the correction\r\n        }\r\n      })\r\n    }\r\n    else {\r\n      this.context.router.push('/playerTwo/'+ this.state.username)\r\n    }\r\n\r\n  }`"}}
{"actor":{"display_login":"hagary"}}