Problem with runContractFunction to return a value

I am using moralis web3 to connect to my smart contract in the front end.
It seems i am having problems with executing and retrieving a function value inside my smart contract.

 const { Moralis, isWeb3Enabled} = useMoralis()
  
  const electionAddress = "0x45eB0c2FDdf1fE0dB656E1900140fD0DED94053e"

  const {runContractFunction: getCandidatesNumber} = useWeb3Contract({
    abi: abi,
    contractAddess: electionAddress ,
    functionName: "getCandidatesNumber", 
    params:{}
  })


  async function updateUIValues() {
      // Another way we could make a contract call:
      // const options = { abi, contractAddress: raffleAddress }
      // const fee = await Moralis.executeFunction({
      //     functionName: "getEntranceFee",
      //     ...options,
      // })

      const number = await getCandidatesNumber()
      console.log(number)
      setcandidatesNumber(number)

  }

  useEffect(() => {
      if (isWeb3Enabled) {
          updateUIValues()
      }
  }, [isWeb3Enabled])

please can someone help me, I am following a youtube guide but i am stuck in this phase. because i can’t console log the value when i am testing.
PS: i tested my getCandidatesNumber() in my hardhat when i deployed and it works.

what happens here?
how is that you can not use console.log?

you can also use vanilla js syntax for Moralis SDK if you can not make it work with react syntax

I am following a guy on youtube for the full/stack web3. idk if you know the tutorial but its in here Patrick Collins
when he reached the part to start using runContractFunction, i followed him, but seems that i cant console.log like him to show the function that return a number from my contract.

can you also provide me a sample code to solve this issue so i can store the val in one of the useStates. Thank you in advance!!

what happens, why would that console.log wouldn’t work?
if you add a console log before calling getCandidatesNumber then it works?

it seems that i can’t even console.log even under the use effect function when (isWeb3Enabled)… idk why any suggestions sir ?

it could be that this useEffect is not called if web3 is not enabled

was web3 enabled?

You are checking for a web3 connection with isWeb3Enabled. You can use isInitialized instead