From fab0c46806c93cc945a64f1107a942f2ca726f4c Mon Sep 17 00:00:00 2001 From: Mitch Oz Date: Fri, 15 Sep 2023 18:31:24 -0600 Subject: [PATCH] fix hydration error --- components/NFTCard.tsx | 15 ++++++---- components/mint.tsx | 2 +- pages/store.tsx | 67 +++++++++++++++++++++++++++--------------- 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/components/NFTCard.tsx b/components/NFTCard.tsx index 49d3106..7f49d12 100644 --- a/components/NFTCard.tsx +++ b/components/NFTCard.tsx @@ -33,7 +33,6 @@ export const NFTCard: React.FC = ({ // const [ipfsData, setIpfsData] = useState({}) as any const [ipfsImage, setIpfsImage] = useState() as any const [tokenPrice, setTokenPrice] = useState('0') - const [tokenURI, setTokenURI] = useState('') const [isInCart, setIsInCart] = useState(false) const [showFadeText, setShowFadeText] = useState(false) const [randomMsg, setRandomMsg] = useState('') @@ -160,22 +159,28 @@ export const NFTCard: React.FC = ({ useEffect(() => { if (tokenInfo) { - const [newTokenPriceHex, newTokenURI] = tokenInfo as [bigint, string] + const [newTokenPriceHex,] = tokenInfo as [bigint, string] setTokenPrice(newTokenPriceHex.toString()) - setTokenURI(newTokenURI) } else if (isTokenInfoError) { console.log(tokenInfoError) } }, [tokenInfo, isTokenInfoError]) + // if (image && name && description && !ipfsImage) { + // getIpfsImage(image).then((res) => { + // setIpfsImage(res) + // } + // ) + // } + useEffect(() => { - if (image) { + if (image && !ipfsImage) { getIpfsImage(image).then((res) => { setIpfsImage(res) } ) } - },[image]) + },[image, ipfsImage, name, description]) useEffect(() => { setTokenSymbol(paymentTokenSymbol) diff --git a/components/mint.tsx b/components/mint.tsx index 2c5b699..9737afc 100644 --- a/components/mint.tsx +++ b/components/mint.tsx @@ -373,7 +373,7 @@ export const MintModal = ({ } return ( -
+
)} - {nftData ? ( + {nftData && nftData.length !== 0 && isAccountConnected ? (
{Array.from({ length: uniqueTokens }).map((_, i) => ( { )}
- {!isRightNetwork && currentNetwork !== undefined && ( + {renderWrongNetwork && (