-
Notifications
You must be signed in to change notification settings - Fork 787
currentObservable.query.fetchMore is not a function #3745
Comments
I have exactly the same issue with calling |
I can confirm that we're getting the same issues on fetchMore of undefined. Mostly it happens when you change route unmounting component that has pending infinity scroll-triggered request. |
The solution we tried (by "checking the route before executing fetchMore") prevents this issue in some cases but not others. The only other solution we have considered is to wrap fetchMore in our own rx.js observable and cancel the call on page changes, but since observables are used in the react-apollo code it seems like the same should be done there. According to a similar issue opened by @RIP21, we are now swallowing the error until a fix or solution apollographql/apollo-client#5291 |
Experienced the same issue with a similar scenario, where we load more on on scroll to bottom.
|
same here . The issue is seen when the onLoadMore is called for infinite scroll. × _this.obsRefetch = function (variables) {
current version in use: "apollo-client": "^2.6.8", |
We've got the same issue @mob-suvee what did you guys exactly check in the route ? |
I've the same issue with
|
Hello All , Are you still facing this issue? I can see this issue still. TypeError: Cannot read property 'fetchMore' of undefined
|
Yes still facing this issue |
Same here |
same problem |
Are you try to implement fetchMore when user scroll ? if yes, i think you have something wrong on your code. you need to remove event scroll, every component is destroy and reassign again. if you. using hook, you can do like this.
|
This happened to me because I was using
After I rewrote it and removed |
We encounter this error when there is page switching to/from a page that calls
useQuery
and attempts to call thefetchMore
function it returns. We have fixed this by checking the route before executing fetchMore, but it seems like something that should be fixed.It looks like a similar issue to this issue: #3368. Looking at the code, I see that this call checks that the currentObservable query exists before calling the function (https://github.com/apollographql/react-apollo/blob/master/packages/hooks/src/data/QueryData.ts#L100) but this call assumes that the query exists and calls it anyway (https://github.com/apollographql/react-apollo/blob/master/packages/hooks/src/data/QueryData.ts#L443). It seems there are a few other places where this pattern occurs in this QueryData file, so it seems a similar fix would be good here.
Intended outcome:
The fetchMore function handles when the currentObservable query does not exist instead of throwing an undefined exception.
Actual outcome:
react-apollo throws
How to reproduce the issue:
On Chrome browser, navigate to/from a page that makes a request with
useQuery
and that will attempt to callfetchMore
to another page (that may or may not make a similar request). When the original request resolves, this error is thrown.Version
react-apollo v3.1.3
System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
Browsers:
Chrome: 79.0.3945.79
Firefox: 71.0
Safari: 13.0.4
The text was updated successfully, but these errors were encountered: