Rendering NFTs owned
import React, { useEffect, useState, useCallback } from 'react';Create the needed states
const [NFTsOwned, setNFTsOwned] = useState([]);
const [hasRespondedNFTs, setHasRespondedNFTs] = useState(false);Ensure waiting for the results by an async function
const fetchNFTsOwned = useCallback(async () => {
let localNFTsOwned = await getNFTsOwned(userAddress);
setHasRespondedNFTs(true);
if (localNFTsOwned) setNFTsOwned(localNFTsOwned);
else setNFTsOwned([]);
}, [userAddress]);Render based on previous states
Render and return the NFTs by cases
This is the branch with the changes done:
Last updated
Was this helpful?
