Skip to content

Conversation

@Joezo
Copy link
Contributor

@Joezo Joezo commented Feb 28, 2019

What does this PR do?

After updating the next.js example with the latest release we noticed that all our data would disappear when fetching more results. The way we recommend to do that is by updating the variables passed into useQuery and supplying an updateData method, which is responsible for merging the previous and new results.

We previously merged a fix (#61) that resets state if variables or query changes in useClientRequest. The fix in this is to only reset the state if updateData is not set. This means that state.data is always populated after the initial request in this scenario.

Checklist

  • I have checked the contributing document
  • I have added or updated any relevant documentation
  • I have added or updated any relevant tests

This prevents there being no data when fetching more results during pagination.
@jackdclark jackdclark self-requested a review February 28, 2019 14:25
Copy link
Contributor

@jackdclark jackdclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@bmullan91 bmullan91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Joezo Joezo merged commit 4bf9e73 into master Feb 28, 2019
@Joezo Joezo deleted the preserve-data-with-update-data branch February 28, 2019 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants