Hi Iām new to react and I am trying to switch from Alchemy to Moralis and use my code from alchemy that was working fine. As of now to test I am simply trying to create a button in my App.js that runs a script when pressed.
In my script I have -
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
export const mintNFT = async (mintAmount) => {
const Web3Api = useMoralisWeb3Api();
console.log("test");
}
And in App.js I try to import -
import { mintNFT } from "./utils/interact.js";
and call -
const onMintPressed = async () => {
const { status } = await mintNFT();
setStatus(status);
};
When clicking the button -
<Button id="mintButton" onClick={onMintPressed}>Mint NFT</Button>
I am getting this error in my script -
Line 5:19: React Hook "useMoralisWeb3Api" is called in function "mintNFT" that is neither a React function component nor a custom React Hook function.
How can I refractor this to work as intended?