{"action":"created","issue":{"url":"https://api.github.com/repos/tylermcginnis/re-base/issues/147","repository_url":"https://api.github.com/repos/tylermcginnis/re-base","labels_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/147/comments","events_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/147/events","html_url":"https://github.com/tylermcginnis/re-base/issues/147","id":186955150,"number":147,"title":"removeBinding interferes with this.setState","user":{"login":"hkhanna","id":222784,"avatar_url":"https://avatars.githubusercontent.com/u/222784?v=3","gravatar_id":"","url":"https://api.github.com/users/hkhanna","html_url":"https://github.com/hkhanna","followers_url":"https://api.github.com/users/hkhanna/followers","following_url":"https://api.github.com/users/hkhanna/following{/other_user}","gists_url":"https://api.github.com/users/hkhanna/gists{/gist_id}","starred_url":"https://api.github.com/users/hkhanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hkhanna/subscriptions","organizations_url":"https://api.github.com/users/hkhanna/orgs","repos_url":"https://api.github.com/users/hkhanna/repos","events_url":"https://api.github.com/users/hkhanna/events{/privacy}","received_events_url":"https://api.github.com/users/hkhanna/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-03T00:27:26Z","updated_at":"2016-11-11T02:47:27Z","closed_at":"2016-11-11T02:47:27Z","body":"When a user logs out, I'd like to remove the `syncState` firebase binding and also set the react state of the component to a logged out state so that the app looks logged out to the user. But for some reason, using `base.removeBinding(this.bindingRef)` before a call to `this.setState({...})` in the same function will prevent the latter command from being executed. \r\n\r\nBelow, I use this combination in the base.onAuth listener, since the passed function fires when the auth state changes (i.e., user logs in, user logs out, or page initially loads). When the user clicks the logout button, the user is logged out on firebase, the onAuth callback properly fires with `user` set to `null`, and the binding is removed. But the call to `this.setState` just never happens.  \r\n\r\n```\r\ncomponentDidMount() {\r\n    base.onAuth((user) => {\r\n      // User logged out\r\n      if(user === null) {       \r\n        if(this.bindingRef) {\r\n          base.removeBinding(this.bindingRef);\r\n          delete this.bindingRef;\r\n        }\r\n\r\n        console.log('This statement is executed.');\r\n\r\n        // THE BELOW STATEMENT IS NOT PROPERLY EXECUTED \r\n        this.setState({ \r\n          data: null,\r\n          user: null,\r\n        });\r\n      }\r\n      // User logged in\r\n      else {\r\n        this.setState({ loading: true });\r\n\r\n        this.bindingRef = base.syncState(`userdata/${user.uid}`, {\r\n          context: this,\r\n          state: 'data',\r\n          then: () => {\r\n            this.setState({ \r\n              user: {\r\n                uid: user.uid,\r\n                email: user.email\r\n              }\r\n            });\r\n          }\r\n        });\r\n      }\r\n    });\r\n  }\r\n```"},"comment":{"url":"https://api.github.com/repos/tylermcginnis/re-base/issues/comments/259867699","html_url":"https://github.com/tylermcginnis/re-base/issues/147#issuecomment-259867699","issue_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/147","id":259867699,"user":{"login":"qwales1","id":2364926,"avatar_url":"https://avatars.githubusercontent.com/u/2364926?v=3","gravatar_id":"","url":"https://api.github.com/users/qwales1","html_url":"https://github.com/qwales1","followers_url":"https://api.github.com/users/qwales1/followers","following_url":"https://api.github.com/users/qwales1/following{/other_user}","gists_url":"https://api.github.com/users/qwales1/gists{/gist_id}","starred_url":"https://api.github.com/users/qwales1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwales1/subscriptions","organizations_url":"https://api.github.com/users/qwales1/orgs","repos_url":"https://api.github.com/users/qwales1/repos","events_url":"https://api.github.com/users/qwales1/events{/privacy}","received_events_url":"https://api.github.com/users/qwales1/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T02:47:27Z","updated_at":"2016-11-11T02:47:27Z","body":"Should be fixed via #146"}}
{"actor":{"display_login":"qwales1"}}