I have a useEffect
hook that is called onMount like so:
const { data, runContractFunction, isLoading } = useWeb3Contract({...}
useEffect(() => {
if (isInitialized)
runContractFunction() //from useWeb3Contract
}, [isInitialized])
useEffect(() => {
console.log(data) // always null unless setting a timeout of 1 sec above
}, [data])
However, the data
from useWeb3Contract
is always null
. If I set a delay on the call by half a second or so then the data is returned correctly. Am I missing something? I would think the isInitialized
check would be all that is needed before calling a function. I have also tried awaiting the runContractFunction
but that does not change anything.