React-apollo: data.loading stays false during a fetchMore

Created on 26 May 2017  Â·  9Comments  Â·  Source: apollographql/react-apollo

Inside render:

  console.log('render', User.length, loading, networkStatus)

When I call data.fetchMore twice, I get:

render 100 false 7
render 200 false 7
render 300 false 7

Whereas I expect:

render 100 false 7
render 100 true 1
render 200 false 7
render 200 true 1
render 300 false 7

Version

Most helpful comment

I think this is an independent issue - we should make sure loading updates correctly even without that option, regardless of the decision for #753.

All 9 comments

@lorensr I'll take a look! Would you be able to isolate this to a reproduction GitHub repo?

Thanks! The repo I linked felt like a small reproduction to me—what should
I take out or what should I isolate?

On Mon, May 29, 2017 at 10:48 PM James Baxley notifications@github.com
wrote:

@lorensr https://github.com/lorensr I'll take a look! Would you be able
to isolate this to a reproduction GitHub repo?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/apollographql/react-apollo/issues/727#issuecomment-304762444,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAPVmCVrKihkmTsxscmXuHyF_sdn-Y8xks5r-4ONgaJpZM4Nm94B
.

Hey @lorensr,

I had the same issue and I investigated a bit.

In ReputationLeaderboard.js, you have to the set notifyOnNetworkStatusChange to true in the options of your container :

export default graphql(usersByReputation, {
  options: {
    variables: {
      offset: USERS_STARTING_OFFSET,
      first: USERS_PER_PAGE
    },
    notifyOnNetworkStatusChange: true
  },
  // ...
})(ReputationLeaderboard)

Only then will you see the data.loading change to true (and networkStatus change to 3, which is the value for fetchMore) in your component.

See documentation about the notifyOnNetworkStatusChange option

I wish it was true by default :/. Or maybe documented in the Pagination recipe !
Could be a PR if you're interested :)

Cheers

Thank you @kombucha! 😄 Suggested the default change in #753

I think this is an independent issue - we should make sure loading updates correctly even without that option, regardless of the decision for #753.

This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if not further activity occurs. Thank you for your contributions to React Apollo!

This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!

This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!

This issue has been automatically closed because it has not had recent activity after being marked as no recent activyt. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to React Apollo!

Was this page helpful?
0 / 5 - 0 ratings