TanStackT
TanStack2y ago
1 reply
awake-maroon

how to define types for querykey?

Hello, a lot of times when I end up with some bugs in my app, i noticed that I was always using wrong querykey with methods such as setQueryData and I was wondering, is there a way to define the types, so that when I use setQueryData I would know that im entering correct queryKey.

export function useGetWeeklyDiaryNew(
  userId: string | undefined | null,
  startDate: string,
  endDate: string
) {
  return useQuery({
    queryKey: [
      'weeklyDiary',
      {
        userId,
        startDate,
        endDate
      }
    ],
Was this page helpful?