Hi guys! I tried to use Moralis web3, Below code is working fine in development, but in production build first refresh it is working, but next time page refresh is not working couldn’t find what is going on.
import {useEffect, useState} from "react";
import {useMoralis} from "react-moralis";
const ActionDetector = () => {
const {web3} = useMoralis();
const [chain, setChain] = useState();
useEffect(() => {
console.log("This code run every page refesh")
console.log("But in production build chain ID is null")
console.log("But if we do hard refresh this is working even production")
console.log(web3.givenProvider.chainId)
console.log("But locally no issue chain id is coming in every refesh")
setChain(web3.givenProvider.chainId)
}, [])
return (
<div>
{chain}
</div>
);
};
export default ActionDetector;