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

Commit

Permalink
Fix runtime error with fast-refresh (#3490)
Browse files Browse the repository at this point in the history
* Fix runtime error with fast-refresh

* Slight code tweak

* Changelog update
  • Loading branch information
jfrolich authored and hwillson committed Sep 14, 2019
1 parent db0fd27 commit 3753b26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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

0 comments on commit 3753b26

Please sign in to comment.