Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Fix runtime error with fast-refresh #3490

Merged
merged 4 commits into from Sep 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Changelog.md
Expand Up @@ -7,7 +7,11 @@
- Calling `startPolling` or `stopPolling` after a component has unmounted is now a no-op (instead of throwing an exception). Polling is automatically stopped when a component is unmounted, so it doesn't need to be called manually. <br/>
[@hwillson](https://github.com/hwillson) in [#3485](https://github.com/apollographql/react-apollo/pull/3485)
- Allow `ignoreResults` to be controlled through `graphql` and `withMutation` options. <br/>
[@tim-stasse](https://github.com/tim-stasse) in [#3431](https://github.com/apollographql/react-apollo/pull/3431)
[@tim-stasse](https://github.com/tim-stasse) in [#3431](https://github.com/apollographql/react-apollo/pull/3431)
- Be a bit more defensive when it comes to accessing the internal
`ObservableQuery` instance, to avoid attempting to use it after a component
has unmounted. <br/>
[@jfrolich](https://github.com/jfrolich) in [#3490](https://github.com/apollographql/react-apollo/pull/3490)

### Bug Fixes

Expand Down
9 changes: 4 additions & 5 deletions packages/hooks/src/data/QueryData.ts
Expand Up @@ -418,11 +418,10 @@ export class QueryData<TData, TVariables> extends OperationData {
}

private handleErrorOrCompleted() {
const {
data,
loading,
error
} = this.currentObservable.query!.getCurrentResult();
const obsQuery = this.currentObservable.query;
if (!obsQuery) return;

const { data, loading, error } = obsQuery.getCurrentResult();

if (!loading) {
const { query, variables, onCompleted, onError } = this.getOptions();
Expand Down