-
Notifications
You must be signed in to change notification settings - Fork 786
Child component stuck in loading state, but the data is already loaded. #2899
Comments
also having this issue |
@OurMajesty Any chance you could try building a reproduction using https://github.com/apollographql/react-apollo-error-template? It will simulate having a backend, so hopefully that will help. |
@hwillson Yes, I did try it right away, but it worked fine. Furthermore, I have found additional places in my app, where it stucks too. For example, dynamic search, that's why I mentioned this issue in #2808. |
If someone needs a workaround, right now I am using react-apollo 2.4.1 along with client 2.5.1 and other latest libraries and doesn't really found any compatibility issues, local state and client queries work fine too. |
@hwillson I did finally reproduced it. The same Codepen link: https://codesandbox.io/s/039pyz78pn First, click on "computer". Result: empty list. |
Having this exact same issue, seems to me that the issue is when variables change but the response remains the same. |
I сonfirm this, updated the reproduction, added another button, which returns not empty data, but the same as "SDK" button, and it is stuck too, if you click them one after another. |
Hello there, I have the exact same issue, when the response is the same, no matter if the filters change, the loading state doesn't change and the component is stuck in a loading state. react-apollo@2.5.2 |
Also experiencing this in |
Same issue.
|
Got the same error with |
I'm experiencing the same problem when the data returned from the previous query is the same as the latest query. |
I am having the exact same Problem, loading State is not updating. Have Version 2.5.4. |
Any update on this, I'm also experiencing this issue. |
Had this issue with My work around was const shouldShowLoading = loading && !data.myData;
if (shouldShowLoading) {
return <Loading />;
}
// use data.myData if it exists
doSomething(data.myData)
|
"apollo-boost": "^0.3.1", This is a clear bug and in my application it happens absolutely randomly. Drove me nuts. Have only one template query and a bunch of client queries/mutations. Wide use of react hooks/custom hooks. |
I did some digging on this issue and the situation addressed here happens when falling into this condition. (https://github.com/apollographql/react-apollo/blob/master/src/Query.tsx#L335-L340) This exists as mentioned in the comments (https://github.com/apollographql/react-apollo/blob/master/src/Query.tsx#L303-L309)
I might be wrong but while above is a valid approach, maybe there is an assumption that In @OurMajesty 's reproduction link, if you press "computer" and "noop" back and forth, |
Also experiencing this issue. On |
I skip/comment the loading condition and it works. |
I have no |
@hwillson some attention on this issue? |
Also having this issue. |
Hi everyone! Thanks for catching this bug, and thank you @OurMajesty for providing a great reproduction. I will continue to investigate the source of this bug, but in the meantime I may have found another workaround. In my tests on the reproduction, it appears that this issue only happens when the query's fetchPolicy is |
|
…3126) * Add ability for Query to detect when lastResult is not accurate * Add regression test for #2899 * Streamline interactions with Apollo Client This commit streamlines some of the React Apollo <--> Apollo Client communication points, to help reduce temporary placeholders and variables used by React Apollo to control rendering. The current data result that is to be rendered now comes from only one place, the initialized `ObservableQuery` instance. * Code review tweaks * Changelog update
A fix for this issue has been merged! Thanks to everyone who helped report and debug this issue |
This thread appeared to be the same issue I'm having except I have now updated to I believe I have found the pattern that is the difference. The issue appears to be caused by having more than one
There is a child component with a 2nd When both requests kick off at the same time (or very close), the loading problem occurs. To be clear, the API requests are coming back fast and successful. They are, in fact, not loading despite the fact If I turn off polling on my parent component ( |
What's the fix? I'm using "apollo-client": "^2.6.2" And noticed this in my HOC when I refresh the page. |
@developdeez The fix was to the internals of how react-apollo keep track of query results, which was merged in #3126. If you use the latest version of react-apollo 2 or 3, this exact problem shouldn't happen anymore. Note that this issue was pretty much exclusively about the |
+1 I have the same problem using react apollo 3 |
This problem is definitely not fixed. |
If anyone here can provide an updated repro that uses React Apollo 3.1.0, we'll take a look. Thanks! |
I'm on 3.1.0 and still loading forever unless using |
I did update my old repro to latest react-apollo and everything works fine: |
@OurMajesty yeah it seems to work fine in your updated sandbox. Congrats! I'm trying to reduce my production code to a minimal example. Are there any good debugging tools for debugging or logging, such as dumping the apollo cache or logging when a query is staying loading too long? |
I would suggest Apollo Dev Tools and also apollo-link-logger |
In React Native app:
same problem. :-( |
Anyone know if this is perhaps fixed in |
I just updated from 3.0.1 to 3.1.1 after seeing your comment and it fixed it for me. Mine was getting stuck loading after getting a 500 from the server using the |
Using |
Also experiencing this and waiting for a fix. @hwillson @jbaxleyiii @helfer @jasonpaulos @ajhool @nmklotas If you can create a minimal repo that reproduces the issue, it'll really help the maintainers in fixing this |
Intended outcome:
There are two React components:
parent: Requests (stateful component)
child: graphql(List), having prop
state
There's buttons in Requests, which are setting state.
In turn, List component's query variable is set by state prop, which is equals to state in Requests component.
So the data for List should be refetched every time I click button in Requests.
Actual outcome:
Data is refetched successfully, but sometimes (80% of times) List is stuck in loading state. If I click some other button again, loading is resolving, the data is new.
I did try install react-apollo 2.4.1 and it fixed the error.
Also, if I recreate component every time (
key
prop) it helps too.BTW, react-apollo@2.5.2 was having the same issue
How to reproduce the issue:
I did create code example using local state, but it works fine, so I suggest the problem reproduction is requiring real graphql endpoint.Real GraphQL endpoint example is failing as expected:
https://codesandbox.io/s/039pyz78pn
Version
The text was updated successfully, but these errors were encountered: