{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/react/issues/6455","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/6455/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/6455/comments","events_url":"https://api.github.com/repos/facebook/react/issues/6455/events","html_url":"https://github.com/facebook/react/issues/6455","id":146879516,"number":6455,"title":"setState( obj, callback) - callback called before state has mutated","user":{"login":"wdiechmann","id":193245,"avatar_url":"https://avatars.githubusercontent.com/u/193245?v=3","gravatar_id":"","url":"https://api.github.com/users/wdiechmann","html_url":"https://github.com/wdiechmann","followers_url":"https://api.github.com/users/wdiechmann/followers","following_url":"https://api.github.com/users/wdiechmann/following{/other_user}","gists_url":"https://api.github.com/users/wdiechmann/gists{/gist_id}","starred_url":"https://api.github.com/users/wdiechmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdiechmann/subscriptions","organizations_url":"https://api.github.com/users/wdiechmann/orgs","repos_url":"https://api.github.com/users/wdiechmann/repos","events_url":"https://api.github.com/users/wdiechmann/events{/privacy}","received_events_url":"https://api.github.com/users/wdiechmann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-08T09:50:38Z","updated_at":"2016-04-08T09:50:38Z","closed_at":null,"body":"I am fighting what used to be called 'a race condition' - I'm not sure what you guys call it in the React world :)\r\n\r\ncalling this snippet in a component\r\n\r\n```\r\n  reportArgs: (e) =>\r\n    console.log( 'later: ' + @state.args)\r\n\r\n  sendPrintRequest: (e) =>\r\n    w = @state.url\r\n    arg = @state.args\r\n    arg = \"komplex string manipulations goes here\"\r\n    @setState {wurl: w, args: arg}, console.log 'sooner ' + @state.args\r\n    setTimeout @reportArgs, 5000\r\n\r\n```\r\nproves my point - I trust.\r\n\r\nEither it is a 'noob observation - go do this instead' or a documentation glitch (as the docs says that the callback is called once the state is mutated) or, eventually, a bug\r\n\r\nObviously I'm rooting for #1 which would have me on my way in a jiffy - providing someone with a lot more knowledge of React would \"stick it to me\" so to speak :)\r\n\r\ncheers,\r\nWalther"}}