3. Disable Auto Data Fetching
To disable auto data fetching after your component has been mounted you can set revalidateOnMount = false. Example:
import { useEvmWalletTokenBalances } from '@moralisweb3/next'
const App = () => {
const { data: balance, fetch } = useEvmWalletTokenBalances({ address: '0x...' }, { revalidateOnMount: false })
return (
<>
<button onClick={fetch}>Fetch Balance Manually</button>
<div>{JSON.stringify(balance, null, 2)}</div>
</>
)
}
It seems useEvmWalletTokenBalances will error if address is not valid, this makes it difficult to implement if address will come from a input field, you would need to do alot of validation against the wallet address Moralis SDK Core Error: [C0005] Invalid address provided