TanStackT
TanStack3y ago
4 replies
technological-jade

Is using 'useCallback' inside 'select' option a good pattern?

I saw somewhere that useCallback should be used inside an expensive select

const { data } = useQuery({
    queryKey: ["myKey", { id }],
    queryFn: myFN,
    select: useCallback((data) => data.slice(0, 9), [id]),
  });

is that still the a good practice?
Was this page helpful?