mirror of
https://github.com/expo/appjs25-eas-update-workshop-code.git
synced 2026-11-14 17:48:09 -10:00
20 lines
463 B
TypeScript
20 lines
463 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { LocalDatabase } from "@/data/api/local-database";
|
|
|
|
export const useFavStatusQuery = function (id: string) {
|
|
// Queries
|
|
const query = useQuery({
|
|
queryKey: [`works:fav:${id}`],
|
|
queryFn: async () => {
|
|
return await fetchFromLocal(id);
|
|
},
|
|
});
|
|
|
|
return query;
|
|
};
|
|
|
|
async function fetchFromLocal(id: string) {
|
|
const db = new LocalDatabase();
|
|
return await db.getFavoriteStatus(id);
|
|
}
|