{"action":"closed","issue":{"url":"https://api.github.com/repos/substance/substance/issues/561","repository_url":"https://api.github.com/repos/substance/substance","labels_url":"https://api.github.com/repos/substance/substance/issues/561/labels{/name}","comments_url":"https://api.github.com/repos/substance/substance/issues/561/comments","events_url":"https://api.github.com/repos/substance/substance/issues/561/events","html_url":"https://github.com/substance/substance/issues/561","id":148976206,"number":561,"title":"willReceiveProps is called initially","user":{"login":"michael","id":2931,"avatar_url":"https://avatars.githubusercontent.com/u/2931?v=3","gravatar_id":"","url":"https://api.github.com/users/michael","html_url":"https://github.com/michael","followers_url":"https://api.github.com/users/michael/followers","following_url":"https://api.github.com/users/michael/following{/other_user}","gists_url":"https://api.github.com/users/michael/gists{/gist_id}","starred_url":"https://api.github.com/users/michael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michael/subscriptions","organizations_url":"https://api.github.com/users/michael/orgs","repos_url":"https://api.github.com/users/michael/repos","events_url":"https://api.github.com/users/michael/events{/privacy}","received_events_url":"https://api.github.com/users/michael/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-17T17:50:54Z","updated_at":"2016-06-13T14:05:58Z","closed_at":"2016-06-13T14:05:58Z","body":"There's a danger of triggering some action twice, though didMount and willReceiveProps if not guarded. I would expect that willReceiveProps is only called if the component already exists, otherwise didMount can be used.\r\n\r\n```js\r\n  this.didMount = function() {\r\n    // load the document after mounting\r\n    this._loadDocument(this.getDocumentId());\r\n  };\r\n\r\n  this.willReceiveProps = function(newProps) {\r\n    if (newProps.documentId !== this.props.documentId) {\r\n      this.dispose();\r\n      // TODO: Use setState instead?\r\n      this.state = this.getInitialState();\r\n      this._loadDocument(this.getDocumentId());\r\n    }\r\n  };\r\n```"}}
{"actor":{"display_login":"oliver----"}}