TanStackT
TanStack3y ago
1 reply
brilliant-lime

Should you use `select` to "transform" data?

I am making a query for an autosuggest and I want to change its shape. Would using select be a bad choice?

useQuery({
  queryKey: ["games"],
  queryFn: getAllGames,
  select(games) {
    return games.map(({ id, title, description }) => ({
      value: id,
      label: title,
      description,
    }));
  }
});
Was this page helpful?