TanStackT
TanStack3y ago
5 replies
precious-lavender

Is `data` always meant to be possibly undefined

Even when using even when using keepPreviousData and placeholderData?

const { data } = useQuery({
  queryKey: taskBoardQueries.weeklyHours({ start }).queryKey,
  queryFn: async () => {
    const response = await taskBoardClient.getWeeklyBillableHours({
      start: start.value,
    });

    const schema = z.object({
      hours: z.number(),
      target: z.number().nullable(),
    });

    return schema.parse(response);
  },
  placeholderData: {
    target: 0,
    hours: 0,
  },
  keepPreviousData: true,
});


Should data.value (Vue) be possible undefined in this case? As far as I know, with this set up, it will never not be defined right?
Was this page helpful?