Open mccraveiro opened 4 years ago
@mccraveiro: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/
@benjamn @hwillson Should I move this PR to the apollo-client repository? This patch will need to be applied on both.
In my project I'm getting the following error with useQuery:
After some debugging, I came into this line: https://github.com/apollographql/react-apollo/blob/4bd40a94b18102b1eb42864d2e59d52ced0303f5/packages/hooks/src/utils/useBaseQuery.ts#L34
Because of the re-render in a microtask this may cause the hook to update the state of an unmounted component. Adding a
isMounted
check fixed the issue.I'm not sure how to add tests for this. Any suggestions?