Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding unnecessary renders on lists after one element updates #8556

Closed
DrWorkhard opened this issue Jul 29, 2021 · 2 comments
Closed

Avoiding unnecessary renders on lists after one element updates #8556

DrWorkhard opened this issue Jul 29, 2021 · 2 comments

Comments

@DrWorkhard
Copy link

Dear community,

First thanks for the great library, I really enjoy working with apollo.

I currently encountered the following performance bottleneck in my app:

  1. I use useQuery to fetch a list of elements and render them
  2. After a click on one of the elements, there is a change in state of this element

Doing this causes a rerender of the whole list. The only workaround I came up with was a second query to fetch the individual list elements. But this this would initially cause querys to the server for each element of the list, something I would like to avoid.

Is there another way I am missing?

Best and thank you
Seb

@benjamn
Copy link
Member

benjamn commented Jul 29, 2021

@DrWorkhard It sounds like you're looking for something like the new useFragment hook that we're planning for Apollo Client v3.5: #8236 (comment)

I'll be opening a draft PR for this work soon, but if you're really interested in the details, here's my working branch: https://github.com/apollographql/apollo-client/commits/wip-useFragment

@DrWorkhard
Copy link
Author

Hi @benjamn awesome, this sounds exactly what I was looking for. So for rendering the list I would use useQuery with fetchpolicy standby and in the specific elements I would use the useFragment hook.

Looking forward to v3.5, thanks for the great work and swift response.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants