Skip to content
Discussion options

You must be logged in to vote

I see nothing wrong with this approach:

const useInit = (select) => {
  queryKey: ['init'],
  queryFn: fetchTodosAndPeople
}

export const usePeople = useInit(data => data.people)
export const useTodos = useInit(data => data.todos)

I have this problem that when updating the todos cache manually, the people reference gets updated too and cause some hooks that depend on people to re-run.

Even if you update people, components that are subscribed to useTodos should not re-render because they are only interested in data.todos. That's what select does.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TomPradat
Comment options

Answer selected by TomPradat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants