Esteves Enzo
add modal
5240c42
raw
history blame
469 Bytes
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
}