Skip to content

Commit

Permalink
refactor: client side with useffect
Browse files Browse the repository at this point in the history
  • Loading branch information
siinghd committed Mar 27, 2024
1 parent a020ec6 commit 9eebe7e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions apps/www/registry/default/ui/nft-card.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect, useState } from "react"
import {
fetchDigitalAsset,
mplTokenMetadata,
Expand Down Expand Up @@ -42,9 +43,19 @@ const NftCard = async ({
mintAddress,
...props
}: NftCardProps) => {
const umi = createUmi(process.env.NEXT_PUBLIC_QUICKNODE!).use(mplTokenMetadata())
const [nftData, setNftData] = useState<any>(null)
const umi = createUmi(process.env.NEXT_PUBLIC_QUICKNODE!).use(
mplTokenMetadata()
)

useEffect(() => {
const fetchNftData = async () => {
const nftData = await fetchDigitalAsset(umi, publicKey(mintAddress))
setNftData(nftData)
}
fetchNftData()
}, [])

const nftData = await fetchDigitalAsset(umi, publicKey(mintAddress))
console.log(nftData)
return (
<div className={cn(nftCardVariants({ variant }), className)} {...props}>
Expand Down

0 comments on commit 9eebe7e

Please sign in to comment.