{"action":"created","issue":{"url":"https://api.github.com/repos/tylermcginnis/re-base/issues/154","repository_url":"https://api.github.com/repos/tylermcginnis/re-base","labels_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/154/labels{/name}","comments_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/154/comments","events_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/154/events","html_url":"https://github.com/tylermcginnis/re-base/issues/154","id":190916730,"number":154,"title":"React + re-base Newbie Question","user":{"login":"joseburgosjr","id":514028,"avatar_url":"https://avatars.githubusercontent.com/u/514028?v=3","gravatar_id":"","url":"https://api.github.com/users/joseburgosjr","html_url":"https://github.com/joseburgosjr","followers_url":"https://api.github.com/users/joseburgosjr/followers","following_url":"https://api.github.com/users/joseburgosjr/following{/other_user}","gists_url":"https://api.github.com/users/joseburgosjr/gists{/gist_id}","starred_url":"https://api.github.com/users/joseburgosjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joseburgosjr/subscriptions","organizations_url":"https://api.github.com/users/joseburgosjr/orgs","repos_url":"https://api.github.com/users/joseburgosjr/repos","events_url":"https://api.github.com/users/joseburgosjr/events{/privacy}","received_events_url":"https://api.github.com/users/joseburgosjr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-22T06:18:52Z","updated_at":"2016-11-24T08:03:10Z","closed_at":null,"body":"I'm having an issue with re-base deleting a key that could just be bad programming on my end. \r\n\r\nSetup: \r\n`componentWillMount() {`\r\n` this.base.syncState('data', {`\r\n`  context: this,`\r\n`  state: 'data'`\r\n` });`\r\n`}`\r\nWhile using React and re-base I have a syncState set on a dataset on componentWillMount, works perfectly, the state is properly set with the corresponding object in Firebase. \r\n\r\nHowever if I try to delete one key from the state via\r\n\r\n`removeFromData(key) {`\r\n`delete this.state.data[key];`\r\n`this.setState({data: this.state.data});`\r\n`}`\r\n\r\n`key` is never deleted in Firebase, but it is deleted from React's state and the component is updated.\r\n\r\nHowever, if I do: \r\n`removeFromData(key) {`\r\n`this.state.data[key] = null;`\r\n`this.setState({data: this.state.data});`\r\n`}`\r\n\r\nThis will update Firebase properly, however it will throw errors within the App due to it expecting properties to be found within `this.state.data[key]`. On page reload it works fine because the key/value pair does not exist within Firebase.\r\n\r\nAm I just improperly using syncState, or perhaps improperly letting React expect there to be a proper key/value pair? My initial thought was that because "},"comment":{"url":"https://api.github.com/repos/tylermcginnis/re-base/issues/comments/262713171","html_url":"https://github.com/tylermcginnis/re-base/issues/154#issuecomment-262713171","issue_url":"https://api.github.com/repos/tylermcginnis/re-base/issues/154","id":262713171,"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-24T08:03:10Z","updated_at":"2016-11-24T08:03:10Z","body":"@joseburgosjr Thanks for posting the examples. I see what you mean now. To answer your first question: I don't think you are not wrong in your thinking at all. It should be setting the parent key to the new value and its not doing that. It is only setting the child keys **that exist** in the new value instead. Making it impossible to use `delete` to remove the key. Will definitely work on a fix for that. \r\n\r\nI think setting the child key to `null` should work though. I am having a hard time reproducing the dangling reference to `null` in the component's state when using that version of `removeFromData`. Reason being when you call `setState` with the new value ( and this is only true when using `syncState`), it doesn't immediately invoke `setState` on the component. It will wait to get the synced value back from firebase before it re-renders and that value would no longer contain `subkey2 : null` . It might be just late and I am overlooking something though 😴 . Will keep trying tomorrow. \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"qwales1"}}