[SOLVED] Web3 Portfolio NFT question

I copied this code from Moralis github, its showing setNFT and setNFTImage as not being read. What am i missing ?

import { useState } from "react";
import styles from "../styles/nft.module.css";
import { Card, Illustration } from "@web3uikit/core";

export default function nft(props) {
  const [nft, setNft] = useState(JSON.parse(props.uri.metadata));
  const [nftImage, setNftImage] = useState(() => {
    if (nft?.image) {
      return nft.image.includes("ipfs")
        ? `https://ipfs.io/ipfs/${nft.image.split("ipfs://")[1]}`
        : nft.image.split("\\")[0];
    }
  });
  let name = nft?.name ? nft.name : "No NFT title can be shown.";

  return (
    <section className={styles.cardContainer}>
      <Card
        onClick={function noRefCheck() {}}
        setIsSelected={function noRefCheck() {}}
        title={name}
      >
        <div>
          {nftImage ? <img src={nftImage} /> : <Illustration logo="lazyNft" />}
        </div>
      </Card>
    </section>
  );
}

Hi @Jthopkins1986
Since the setNFT and setNFTImage of useState are not used anywhere in the code. You can either ignore the errors using //@ts-ignore or use them in your code to update the nft and nftImage state variables.

1 Like