Replies: 1 comment 1 reply
-
thanks for the detailed reproductions.
I'm not sure what that means exactly? Which scheduler have you modified? I've tried the react18 version on a new sandbox with no modifications to react-query or react and it runs fine: https://codesandbox.io/s/festive-chaum-gonecu?file=/src/index.jsx so maybe there used to be an issue in react that has been fixed? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working with a project that has started using React Query in conjunction with Loadable Components.
We have a RQ query that gets run in both a component that gets immediately rendered and a component that gets loaded as a Loadable Component. The latter component sometimes doesn't get re-rendered with the query's latest data.
I've added debug logs to various places and the issue seems to happen when the order of events is like
One workaround we found is to add an
useEffect
hook that forces the loaded component to re-render once.Here is a simplified version of the project, which is on React 16.9.0:
16.9-repro | codesandbox (You may need to adjust how long it takes to 'fetch' the remote data in queries.js. One number that worked in codesandbox for me is 700ms, although I needed to reload a few times to see it repro. The repro rate is closer to 100% when I run it locally)
16.9-workaround | codesandbox
The issue actually seems to go away when I upgrade to React 16.10.0. Bisecting the react repo's commits pointed to a commit that enables MessageLoop implementation of the scheduler by default as the one that fixed the issue.
However, when I modified the scheduler to always run out of time per loop, the issue surfaced again. The same workaround of forcing a re-render still works.
16.10-repro | codesandbox
16.10-workaround | codesandbox
The same thing happens with React v18: modifying the scheduler to always run out of time per loop reproduces the issue, and forcing a re-render fixes the issue.
18.2-repro | codesandbox
18.2-workaround | codesandbox
Having no real understanding of how these libraries should work in this situation, I'm not sure how to assess the issue.
Beta Was this translation helpful? Give feedback.
All reactions