SolanaAPI Uncaught TypeError: Cannot read properties of undefined (reading 'getPortfolio')

Hi,

I’m using the boilerplate React code as below but getting the error shown, what am I missing?

import { useMoralisSolanaApi, useMoralisSolanaCall } from “react-moralis”;

const { account } = useMoralisSolanaApi();

const { fetch, data, isLoading } = useMoralisSolanaCall(account.getNFTs);

Error

Uncaught TypeError: Cannot read properties of undefined (reading ‘getPortfolio’)
at CheckNFTPage (CheckNfts.js:52:1)
at renderWithHooks (react-dom.development.js:16141:1)
at mountIndeterminateComponent (react-dom.development.js:20838:1)
at beginWork (react-dom.development.js:22342:1)
at beginWork$1 (react-dom.development.js:27219:1)
at performUnitOfWork (react-dom.development.js:26392:1)
at workLoopSync (react-dom.development.js:26303:1)
at renderRootSync (react-dom.development.js:26271:1)
at recoverFromConcurrentError (react-dom.development.js:25689:1)
at performConcurrentWorkOnRoot (react-dom.development.js:25589:1)

that error may be from some other place in the code?

I don’t see here in those 3 lines that getPortfolio

Damn, copied the wrong error to the wrong code.But the same problem still applies. It’s really simple code and it doesn’t seem to work:

import { useMoralisSolanaApi, useMoralisSolanaCall } from “react-moralis”;

const { account } = useMoralisSolanaApi();

const { fetch, data, isLoading } = useMoralisSolanaCall(account.getPortfolio);

this would mean that account is undefined at that moment
you could try to add some logging with console.log

You’re still getting Cannot read properties of undefined (reading ‘getPortfolio’)?

This basic example based on the documentation code works fine:

const { account } = useMoralisSolanaApi();

const { data, isLoading } = useMoralisSolanaCall(
  account.getPortfolio,
  {
    network: 'devnet',
    address: '6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe',
  },
  {
    autoFetch: true,
  }
);

useEffect(() => {
  console.log('data', data);
}, [data]);

Are you on the latest react-moralis?