-
Notifications
You must be signed in to change notification settings - Fork 787
[Hooks] fetchMore option updateQuery triggers hook update but with previous data #3333
Comments
Are you sure you're using the correct argument? The first argument passed to |
@AlpacaGoesCrazy did #3333 (comment) help you with this? If not, would you mind providing a small runnable reproduction that shows this is a problem? |
@hwillson it did not help, but after some research I determined the source of the problem and made a reproduction. |
reproduction updated to [email protected] [email protected] problem is still here |
I figured out a workaround for this issue, here we use separate |
"@apollo/react-hoc@^3.0.0" |
Thanks for the great reproduction @AlpacaGoesCrazy. We've found the issue and will have a fix ready shortly. |
Prior to this commit, when `notifyOnNetworkStatusChange` is true calls to `fetchMore` do not wait for `updateQuery` to finish, before triggering a re-render. This means that after a `fetchMore` call, components will flip to `loading: true`, then `loading: false`, then un-necessarily re-render once more as `loading: false` with the result from `updateQuery`. This commit adds a check to see if `fetchMore` has been called and then holds off on re-rendering the `loading: false` state, until `updateQuery` has fully finished. Fixes #3333
Prior to this commit, when `notifyOnNetworkStatusChange` is true calls to `fetchMore` do not wait for `updateQuery` to finish, before triggering a re-render. This means that after a `fetchMore` call, components will flip to `loading: true`, then `loading: false`, then un-necessarily re-render once more as `loading: false` with the result from `updateQuery`. This commit adds a check to see if `fetchMore` has been called and then holds off on re-rendering the `loading: false` state, until `updateQuery` has fully finished. Fixes #3333
Prior to this commit, when `notifyOnNetworkStatusChange` is true calls to `fetchMore` do not wait for `updateQuery` to finish, before triggering a re-render. This means that after a `fetchMore` call, components will flip to `loading: true`, then `loading: false`, then un-necessarily re-render once more as `loading: false` with the result from `updateQuery`. This commit adds a check to see if `fetchMore` has been called and then holds off on re-rendering the `loading: false` state, until `updateQuery` has fully finished. Fixes #3333
@hwillson [email protected] breaks this again and further versions are broken as well :( |
Just a quick note here - this is fixed in the |
bug happening again :( |
It's happening when using |
I'm noticing the same problem with In what version has this been fixed? |
While implementing pagination with
fetchMore
and it's optionsupdateQuery
where I merge new list data with what I initially queried, I noticed that afterfetchMore
is calleduseQuery
hook updates my component with the previous data without the update I provided inupdateQuery
, however the nextfetchMore
call results in the data I should have received in the previousfetchMore
update (and so on)Intended outcome:
To get in
data
object ofuseQuery
hook result ofupdateQuery
function which was provided as option infetchMore
call.Actual outcome:
Getting in
data
object inuseQuery
hook PREVIOUS result ofupdateQuery
function which was provided as option infetchMore
call or original result of a query (if it was the first call tofetchMore
) .Version
[email protected]
The text was updated successfully, but these errors were encountered: