Intended outcome:
loading being true while the fetchMore request is done, then merging the results with updateQuery, then rerendering with loading to false.
Actual outcome:
When fetchMore gets an empty array from the server, updateQuery is called as it should be, but the component never rerenders, thus loading being indefinitely true.
Version
@apollo/react-hooks : 3.1.0
The problem started with this version.
3.0.1 worked fine.
Not sure if this would help anyone but I resolved this because my fetchMore was unnecessarily being called immediately after render. After fixing that the issue stopped.
That is not my case, and everything was fine in version 3.0.1. I don't think this comes from my code.
I'm also experiencing this issue. networkStatus is stuck on 3, fetch more. This is with hooks 3.1.1 and apollo-client 2.6.4. Mine isn't being triggered immediately after render either.
It seems like this happens when updateQuery returns previousQueryResult, regardless of the result, as the component isn't re-rendered.
Forcing a render fixes it.
I created a reproduction for this bug: https://codesandbox.io/s/reproduction-for-react-apollo-3468-jt3b5
@hwillson this seems like it could be related to PR #3433
P.S. I love using addMockFunctionsToSchema in my client side tests, it's so much easier when the data is mocked automatically
@dylanwulf I think your reproduction is for a different bug. This issue happens with a successful response of an empty array when no other data/state changes.
@dylanwulf I think your reproduction is for a different bug. This issue happens with a successful response of an empty array when no other data/state changes.
@scf4 I am fairly confident that both issues are caused by the same bug, but just in case I created another reproduction with a successful response of empty array: https://codesandbox.io/s/reproduction-for-react-apollo-3468-with-successful-response-p4gmo
@dylanwulf Oops, yeah I see what you're saying now. 馃憤
Same happens here, building pagination components and when I get a empty array response from the API the loading get stucked and it is not updated.
It looks like a fix has been proposed but it has not been merged https://github.com/apollographql/react-apollo/pull/3514
I am also experiencing the bug described by @scf4 . When I use fetchMore, it successfully makes the network request, but networkStatus is stuck on 3, and loading is stuck on true, but only when the result of fetchMore is the same as the previous result.
I am experiencing this with:
"react-apollo": "^3.0.1",
"apollo-client": "^2.5.1",
https://github.com/apollographql/react-apollo/pull/3514 has been merged, and will be deployed shortly. Thanks all!
@hwillson have you deployed it? Because I still have this problem
Most helpful comment
https://github.com/apollographql/react-apollo/pull/3514 has been merged, and will be deployed shortly. Thanks all!