Skip to content

Lesson:10 TypeError: Cannot read properties of undefined (reading 'toString') #1165

Discussion options

You must be logged in to vote

Hii, useState returns an array...., For first error please check you are passing right contractAddress, abi, and functionName

import { abi, contractAddresses } from "../constants/index"
import { useMoralis, useWeb3Contract } from "react-moralis"
import { useEffect, useState } from "react"

export default function LotteryEntrance() {
    const { chainId: chainIdHex, isWeb3Enabled } = useMoralis()
    const chainId = parseInt(chainIdHex)
    console.log(chainId)
    const raffleAddress = chainId in contractAddresses ? contractAddresses[chainId][0] : null
-    let { entranceFee, setEntranceFee } = useState("0")
+   const [entranceFee, setEntranceFee ] = useState("0");
 
+   // Make sure you …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sunil-Reddy-Gummalla
Comment options

Answer selected by Sunil-Reddy-Gummalla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants