mirror of
https://github.com/expo/appjs24-workflows-workshop-code.git
synced 2026-11-15 17:29:20 -10:00
17 lines
401 B
TypeScript
17 lines
401 B
TypeScript
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
|
const data = require("../api/cma_artwork.json");
|
|
|
|
export const useWorkByIdQuery = function(id: string) {
|
|
const queryClient = useQueryClient();
|
|
|
|
// Queries
|
|
const query = useQuery({
|
|
queryKey: [`works:${id}`],
|
|
queryFn: async () => {
|
|
return data.data.find((item: any) => item.id == id);
|
|
},
|
|
});
|
|
|
|
return query;
|
|
} |