{"action":"created","issue":{"url":"https://api.github.com/repos/contiamo/restful-react/issues/71","repository_url":"https://api.github.com/repos/contiamo/restful-react","labels_url":"https://api.github.com/repos/contiamo/restful-react/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/contiamo/restful-react/issues/71/comments","events_url":"https://api.github.com/repos/contiamo/restful-react/issues/71/events","html_url":"https://github.com/contiamo/restful-react/issues/71","id":370330561,"node_id":"MDU6SXNzdWUzNzAzMzA1NjE=","number":71,"title":"<Get /> may try to update state when component unmounts","user":{"login":"carlesba","id":1178459,"node_id":"MDQ6VXNlcjExNzg0NTk=","avatar_url":"https://avatars0.githubusercontent.com/u/1178459?v=4","gravatar_id":"","url":"https://api.github.com/users/carlesba","html_url":"https://github.com/carlesba","followers_url":"https://api.github.com/users/carlesba/followers","following_url":"https://api.github.com/users/carlesba/following{/other_user}","gists_url":"https://api.github.com/users/carlesba/gists{/gist_id}","starred_url":"https://api.github.com/users/carlesba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlesba/subscriptions","organizations_url":"https://api.github.com/users/carlesba/orgs","repos_url":"https://api.github.com/users/carlesba/repos","events_url":"https://api.github.com/users/carlesba/events{/privacy}","received_events_url":"https://api.github.com/users/carlesba/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-15T20:28:19Z","updated_at":"2018-10-16T09:59:33Z","closed_at":null,"author_association":"NONE","body":"**Describe the bug**\r\n\r\n`fetch` method in `Get.tsx` could resolve the promise when component gets unmounted. This would call `this.setState` when component is not longer rendered what makes react to throw an error.\r\n\r\n**To Reproduce**\r\n\r\nIn a test:\r\n\r\n1. mount `Get` fetching for some resource.\r\n2. create a `nock` instance that delays the response long enough to unmount the component before it resolves the request.\r\n3. unmount the component and check the output. The error should be there.\r\n\r\n**Expected behavior**\r\n\r\n`setState` should not be called after component unmounts.\r\n\r\n*A* solution here could be creating *cancelable promises* when fetching. Then keep track of pending requests in the instance of the component and cancelling the all the requests when component unmounts. `fetch` should not call `setState` when the request is cancelled.\r\n\r\n**Screenshots**\r\n<img width=\"1272\" alt=\"unmounted\" src=\"https://user-images.githubusercontent.com/1178459/46976211-1a1e5700-d0c9-11e8-994e-d6900b22d495.png\">\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/contiamo/restful-react/issues/comments/430177771","html_url":"https://github.com/contiamo/restful-react/issues/71#issuecomment-430177771","issue_url":"https://api.github.com/repos/contiamo/restful-react/issues/71","id":430177771,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDE3Nzc3MQ==","user":{"login":"TejasQ","id":9947422,"node_id":"MDQ6VXNlcjk5NDc0MjI=","avatar_url":"https://avatars1.githubusercontent.com/u/9947422?v=4","gravatar_id":"","url":"https://api.github.com/users/TejasQ","html_url":"https://github.com/TejasQ","followers_url":"https://api.github.com/users/TejasQ/followers","following_url":"https://api.github.com/users/TejasQ/following{/other_user}","gists_url":"https://api.github.com/users/TejasQ/gists{/gist_id}","starred_url":"https://api.github.com/users/TejasQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TejasQ/subscriptions","organizations_url":"https://api.github.com/users/TejasQ/orgs","repos_url":"https://api.github.com/users/TejasQ/repos","events_url":"https://api.github.com/users/TejasQ/events{/privacy}","received_events_url":"https://api.github.com/users/TejasQ/received_events","type":"User","site_admin":false},"created_at":"2018-10-16T09:59:33Z","updated_at":"2018-10-16T09:59:33Z","author_association":"MEMBER","body":"Great issue! Thanks for the report! Would you like to create a PR?"}}
{"actor":{"display_login":"TejasQ"}}