Spaces:
Runtime error
Runtime error
import { useMemo, useState } from "react" | |
import { useQueryClient } from "@tanstack/react-query" | |
import { Collection } from "@/utils/type" | |
export const useCollection = (id: number) => { | |
const client = useQueryClient() | |
const collection = useMemo(() => { | |
const collections = client.getQueryData<Collection[]>(["collections"]) | |
if (!collections) return null | |
return collections.find((collection) => collection.id === id) | |
}, [id]) | |
return collection | |
} |