mirror of
https://github.com/expo/appjs25-eas-update-workshop-code.git
synced 2026-11-14 17:48:09 -10:00
24 lines
553 B
TypeScript
24 lines
553 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { uniqBy } from "lodash";
|
|
|
|
const data = require("../api/cma_artwork.json");
|
|
const departments = uniqBy(
|
|
data.data,
|
|
(item: { department: string; images: any }) => item.department,
|
|
);
|
|
|
|
export const useDepartmentsQuery = function () {
|
|
// Queries
|
|
const query = useQuery({
|
|
queryKey: [`departments`],
|
|
queryFn: async () => {
|
|
return departments.map((item) => ({
|
|
department: item.department,
|
|
imageUrl: item.images.web.url,
|
|
}));
|
|
},
|
|
});
|
|
|
|
return query;
|
|
};
|