You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 2, 2024. It is now read-only.
I have a question around a more complex, but probably common use case of multiple use-fetch hooks in a component tree. Maybe you have run into this before.
Suppose you have a todo app, where the header contains a count of open todos. This count comes from a use-fetch hook /api/todos and looks at the resulting data.length. There's a child component which renders a list of the todos using the same API, but a different hook. If I close one of the open todos in the list, and refetch, the list will update, but the count will be stale, even though the hooks read from the same caching key. At least, I believe that is true?
Do you have any recommendations for notifying the parent component that the cache is updated? The simplest approach would be to pass down the doFetch from the parent to child. But, this gets pretty messy if there's lots of nesting. It gets even more complicated if the API that has the count is different than the one which has the list.