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

Feature: useBackgroundQuery hook #8694

Closed
hwillson opened this issue Aug 24, 2021 · 5 comments
Closed

Feature: useBackgroundQuery hook #8694

hwillson opened this issue Aug 24, 2021 · 5 comments

Comments

@hwillson
Copy link
Member

hwillson commented Aug 24, 2021

This is a placeholder issue for tracking purposes. Details in #8783.

this new useBackgroundQuery hook allows a component to fetch data in a way that's managed by the React component lifecycle, without automatically subscribing to every future change in that data, allowing child components to update in place without requiring the parent component to rerender all its children.

in other words: useBackgroundQuery executes as soon as the component mounts and can be used as a render optimization so you can ensure your component doesn't oversubscribe to data changing in the cache that it doesn't care about which can help you avoid some rerenders. The prime use case for this is lists. You might not want a parent component to rerender every time data from a single item in the list is updated.

@jpvajda
Copy link
Contributor

jpvajda commented Apr 26, 2022

@hwillson should this issue reference #8783? it seems to be pointing to itself. 😄

@hwillson
Copy link
Member Author

Ooops - fixed, thanks @jpvajda! 🙇

@hwillson hwillson assigned alessbell and unassigned benjamn Jul 19, 2022
@jpvajda jpvajda removed this from the Release 3.7 milestone Jul 26, 2022
@jpvajda jpvajda added this to the Release 3.8 milestone Jul 26, 2022
@alessbell alessbell changed the title Feature: useBackgroundQuery hook Feature: useBackgroundQuery hook Feb 3, 2023
@alessbell
Copy link
Contributor

Our new design for useBackgroundQuery is as a data fetching hook that's part of Apollo Client's Suspense story: it will provide a way to initiate queries in the "background" while rendering continues until a component consuming the data further down the render tree throws a promise and suspends, thus enabling the "render as you fetch" pattern.

This diverges from the original design of the hook described in this issue as one that pairs with useFragment to allow list items to update in place, which will be solved by a @nonreactive directive.

@alessbell
Copy link
Contributor

This work was completed in #10755 and will be released with the next 3.8 alpha 🎉

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

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