I have the following custom hook called useGetQuery
type Props = Parameters<typeof useQuery>;const useGetQuery = (...params: Props) => { const useQueryResults = useQuery(params); useFocusEffect( React.useCallback(() => { useQueryResults.refetch(); }, [useQueryResults]) ); return useQueryResults;};
Which I then call in useGetScreen
like this:
export const useGetScreen = (screenId: string) => { return useGetQuery(['getScreen', { screenId }], () => getScreen(screenId), { staleTime: 0 });};
And useGetScreen
is called like this
const { data: screen } = useGetScreen('vegetables');
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