{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2079","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2079/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2079/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2079/events","html_url":"https://github.com/Automattic/wp-calypso/pull/2079","id":124819346,"number":2079,"title":"Editor: Move initial connection fetching to didMount","user":{"login":"aduth","id":1779930,"avatar_url":"https://avatars.githubusercontent.com/u/1779930?v=3","gravatar_id":"","url":"https://api.github.com/users/aduth","html_url":"https://github.com/aduth","followers_url":"https://api.github.com/users/aduth/followers","following_url":"https://api.github.com/users/aduth/following{/other_user}","gists_url":"https://api.github.com/users/aduth/gists{/gist_id}","starred_url":"https://api.github.com/users/aduth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduth/subscriptions","organizations_url":"https://api.github.com/users/aduth/orgs","repos_url":"https://api.github.com/users/aduth/repos","events_url":"https://api.github.com/users/aduth/events{/privacy}","received_events_url":"https://api.github.com/users/aduth/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Editor","name":"Editor","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Sharing","name":"Sharing","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Status]%20Needs%20Review","name":"[Status] Needs Review","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"aduth","id":1779930,"avatar_url":"https://avatars.githubusercontent.com/u/1779930?v=3","gravatar_id":"","url":"https://api.github.com/users/aduth","html_url":"https://github.com/aduth","followers_url":"https://api.github.com/users/aduth/followers","following_url":"https://api.github.com/users/aduth/following{/other_user}","gists_url":"https://api.github.com/users/aduth/gists{/gist_id}","starred_url":"https://api.github.com/users/aduth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduth/subscriptions","organizations_url":"https://api.github.com/users/aduth/orgs","repos_url":"https://api.github.com/users/aduth/repos","events_url":"https://api.github.com/users/aduth/events{/privacy}","received_events_url":"https://api.github.com/users/aduth/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-01-04T19:12:16Z","updated_at":"2016-01-04T19:25:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/2079","html_url":"https://github.com/Automattic/wp-calypso/pull/2079","diff_url":"https://github.com/Automattic/wp-calypso/pull/2079.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/2079.patch"},"body":"This pull request seeks to resolve an issue where a `setState` error is invoked after attempting to make an initial request for connections in the post editor.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1779930/12097933/ad71f9a6-b2ec-11e5-9b94-7c65440f6baf.png)\r\n\r\nThe initial fetch should occur after the component has mounted, not in the constructor. The class constructor's relation to lifecycle methods [is a bit confusing](https://twitter.com/dan_abramov/status/576453138598723585), though notably calls to `setState` cannot occur in the constructor.\r\n\r\n__Testing instructions:__\r\n\r\nVerify that the error is not presented, and that connections continue to load as expected.\r\n\r\n1. Navigate to the [Calypso post editor](http://calypso.localhost:3000/post)\r\n2. Select a site, if prompted\r\n3. Note that no `setState` errors are shown in the developer tools console\r\n4. Note that sharing connections are accurately reflected after load in the Sharing accordion\r\n\r\n__Future tasks:__\r\n\r\n`EditorSharingContainer` is relatively new, though I already want to refactor it to move connections fetching further up the render chain (see [\"Fetching Components\"](https://github.com/Automattic/wp-calypso/blob/add/docs-data-approach/docs/our-approach-to-data.md#fetching-components) distinction).\r\n\r\n/cc @timmyc "},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/168777141","html_url":"https://github.com/Automattic/wp-calypso/pull/2079#issuecomment-168777141","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2079","id":168777141,"user":{"login":"aduth","id":1779930,"avatar_url":"https://avatars.githubusercontent.com/u/1779930?v=3","gravatar_id":"","url":"https://api.github.com/users/aduth","html_url":"https://github.com/aduth","followers_url":"https://api.github.com/users/aduth/followers","following_url":"https://api.github.com/users/aduth/following{/other_user}","gists_url":"https://api.github.com/users/aduth/gists{/gist_id}","starred_url":"https://api.github.com/users/aduth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduth/subscriptions","organizations_url":"https://api.github.com/users/aduth/orgs","repos_url":"https://api.github.com/users/aduth/repos","events_url":"https://api.github.com/users/aduth/events{/privacy}","received_events_url":"https://api.github.com/users/aduth/received_events","type":"User","site_admin":false},"created_at":"2016-01-04T19:25:22Z","updated_at":"2016-01-04T19:25:22Z","body":">Where do you think the fetching of redux data should live for the editor components like this?\r\n\r\nIdeally, a `<PostEditorData />` component rendered at the router level ([similar to `<PreferencesData />`](https://github.com/Automattic/wp-calypso/blob/fb1df04cd9d65ff7be4a238b415bd93270feebb1/client/post-editor/controller.js#L43-L53)), managing all data fetching needs for the post editor. This will make it much easier to have connected components accepting minimal props without concerning themselves with fetching behaviors.\r\n\r\ne.g. The entire sharing accordion doesn't need to know about and pass down connections, as only a few of the descendent components make use of them. It would be nice if those components could pull connections directly from the state tree using `react-redux`, as this promotes the idea of component self-sufficiency and makes it much easier to use pure render mixins (`<EditorSharingPublicizeServices />` accepting only `siteId` number, not a `connections` array)."}}