File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ export class Query extends PureComponent<Props, State> {
8686
}
8787

8888
try {
89-
this.setResponse(QueryCache.getEndpointCache(endpoint));
89+
const cachedResponse = QueryCache.getEndpointCache(endpoint);
90+
// This condition should never be falsy, because QueryCache throws if no
91+
// data is stored for given endpoint. But Flow is not able to detect this
92+
if (cachedResponse) {
93+
this.setResponse(cachedResponse);
94+
}
9095
} catch (_) {
9196
this.fetchData(endpoint, enableCache);
9297
}
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ it('is able to refetch from original endpoint', () => {
113113
</Query>
114114
</Provider>,
115115
);
116-
renderRefetch();
116+
if (renderRefetch) renderRefetch();
117117
expect(readEndpoint).toHaveBeenCalledWith('/posts');
118118
expect(readEndpoint).toHaveBeenCalledTimes(2);
119119
});
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* @flow strict */
1+
/* @flow strict-local */
22

33
import Query from './Query';
44

0 commit comments

Comments
 (0)