T
TanStack4y ago
rising-crimson

is destructuring useQuery to return from custom hook bad?

im seeing some unexpected calls / rendering behaviour doing this kind of thing in a custom hook - is this just bad and i should only return useQuery() itself? export const usePreferences = () => { const { authState } = useAuth(); const query = useQuery(["preferences", authState?.isAuthenticated], () => fetchApi("/preferences") ); console.count("preferences"); return { preference1: query?.data?.preference1, preference2: query?.data?.preference2, isLoading: query.isLoading, isError: query.isError, }; };
2 Replies
adverse-sapphire
adverse-sapphire4y ago
no, this doesn't make a difference.
rising-crimson
rising-crimsonOP4y ago
okay thanks, then it must be elsewhere

Did you find this page helpful?