diff --git a/templates/base/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts b/templates/base/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts index 379785901..3d58526cd 100644 --- a/templates/base/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts +++ b/templates/base/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts @@ -37,12 +37,13 @@ export function useDeployedContractInfo( const finalConfig: UseDeployedContractConfig = typeof configOrName === "string" ? { contractName: configOrName } : (configOrName as any); - if (typeof configOrName === "string") { - console.warn( - "Using `useDeployedContractInfo` with a string parameter is deprecated. Please use the object parameter version instead.", - ); - } - + useEffect(() => { + if (typeof configOrName === "string") { + console.warn( + "Using `useDeployedContractInfo` with a string parameter is deprecated. Please use the object parameter version instead.", + ); + } + }, [configOrName]); const { contractName, chainId } = finalConfig; const selectedNetwork = useSelectedNetwork(chainId); const deployedContract = contracts?.[selectedNetwork.id]?.[contractName as ContractName] as Contract; diff --git a/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts b/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts index c061ce464..c6707c709 100644 --- a/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts +++ b/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { MutateOptions } from "@tanstack/react-query"; import { Abi, ExtractAbiFunctionNames } from "abitype"; import { Config, UseWriteContractParameters, useAccount, useWriteContract } from "wagmi"; @@ -60,11 +60,13 @@ export function useScaffoldWriteContract( : (configOrName as UseScaffoldWriteConfig); const { contractName, chainId, writeContractParams: finalWriteContractParams } = finalConfig; - if (typeof configOrName === "string") { - console.warn( - "Using `useScaffoldWriteContract` with a string parameter is deprecated. Please use the object parameter version instead.", - ); - } + useEffect(() => { + if (typeof configOrName === "string") { + console.warn( + "Using `useScaffoldWriteContract` with a string parameter is deprecated. Please use the object parameter version instead.", + ); + } + }, [configOrName]); const { chain: accountChain } = useAccount(); const writeTx = useTransactor();