Skip to content
Discussion options

You must be logged in to vote

Hi @alexnguyennz , I think you might need to iterate over all of those anyways, but you can create a hook to abstract that logic for you:

const useQueriesWithRefetch = (...queries) => {
	const results = useQueries(...queries);

	const refetchAll = useCallback(() => {
		results.forEach(result => result.refetch());
	}, [results]);

	return {
		queries,
		refetchAll,
	};
};

Replies: 1 comment 1 reply

Comment options

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

Answer selected by alexnguyennz
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