Hello,
This code works perfectly;
import { useChain } from "react-moralis";
function Chains() {
const { switchNetwork, chainId, chain, account } = useChain();
return (
<>
<button onClick={() => switchNetwork("0x1")}>Switch to Ethereum</button>
<p>Current chainId: {chainId}</p>
</>
);
}
But when i try to {chain.name} instead of {chainId} whole React app has been crashing and getting this error;
Uncaught TypeError: Cannot read properties of null (reading βnameβ)
What is the problem? Thanks.