[SOLVED] What this error means? Caused by getNftBalances

Unhandled Runtime Error

TypeError: getNftBalances is not a function

image


code as below :
import { useEffect } from "react"
import { useNFTBalances } from "react-moralis"
import CustomContainer from "./CustomContainer"

export default function Nft({ user }) {

  const { getNftBalances, data } = useNFTBalances()

  useEffect(() => {

    getNftBalances({
      params: {
        chain: "ropsten",
        address: user.get('ethAddress'),
      }
    })
  }, [getNftBalances, user])
  console.log(data)
  return (
    <CustomContainer>
      I am NFT
    </CustomContainer>
  )
}

package.json :

{
  "name": "moralis-dashboard3",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@chakra-ui/react": "^1.8.8",
    "@emotion/react": "^11",
    "@emotion/styled": "^11",
    "@walletconnect/web3-provider": "^1.7.7",
    "@web3auth/web3auth": "^0.9.0",
    "framer-motion": "^6",
    "magic-sdk": "7.0.0",
    "moralis": "^1.5.9",
    "next": "12.1.5",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-moralis": "^1.3.5"
  },
  "devDependencies": {
    "eslint": "8.13.0",
    "eslint-config-next": "12.1.5"
  }
}

structure:

image

A little typo here, The getNFTBalances is case sensitive.
It should be getNFTBalances not getNftBalances

3 Likes

Appreciate for your warm help. Solved.