I have the following custom hook called useFocusRefetchQuery
type Props = Parameters<typeof useQuery>;const useFocusRefetchQuery = (...params: Props) => { const useQueryResults = useQuery(params); useFocusEffect( React.useCallback(() => { useQueryResults.refetch(); }, [useQueryResults]) ); return useQueryResults;};
Which I then call in useGetArticle
like this:
export const useGetArticle = (articleId: string) => { return useFocusRefetchQuery(['getArticle', { articleId }], () => getArticle(articleId), { staleTime: 0 });};
And useGetArticle
is called like this
const { data: article, isLoading } = useGetArticle('home');
My problem is that in this case, article has a type of unknown
and I can't figure out why is this happening. My guess is that I have to somehow type what is being returned by useFocusRefetchQuery. Before I implemented the custom hook, Typescript automatically inferred the return type of useQuery