Files
js/@3rdweb-sdk/react/hooks/useWalletNFTs.ts
T
Nacho Iacovino 77cb9dfa57 Display NFTs on account page (#1478)
* Display NFTs on account page

* Add account balance component

* Fix copy
2023-08-03 00:29:33 +00:00

25 lines
767 B
TypeScript

import { useQueryWithNetwork } from "./query/useQueryWithNetwork";
import { useDashboardEVMChainId } from "./useActiveChainId";
import { useAddress } from "@thirdweb-dev/react";
import { WalletNFTApiReturn } from "pages/api/wallet/nfts/[chainId]";
export function useWalletNFTs(walletAddress?: string) {
const activeChainId = useDashboardEVMChainId();
const connectedAddress = useAddress();
const address = walletAddress || connectedAddress;
return useQueryWithNetwork(
["walletNfts", address],
async () => {
const response = await fetch(
`/api/wallet/nfts/${activeChainId}?owner=${address}`,
);
return (await response.json()) as WalletNFTApiReturn;
},
{
enabled: !!address && !!activeChainId,
},
);
}