Spaces:
Runtime error
Runtime error
File size: 469 Bytes
5240c42 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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
} |