[solved] Error using useChain and switchNetwork - ReactApp

I get this error while trying to use the switchNetwork to change my chain id
Missing web3 instance, make sure to call Moralis.enableWeb3() or Moralis.authenticate()

is there a proper way to do it in react assuming the following were available in my code

import { useChain } from “react-moralis”;

const { switchNetwork } = useChain();
switchNetwork(“0x61”);

I think that you have enableWeb3 hook in react

2 Likes

yes worked this way

import { useMoralis, useChain} from “react-moralis”;

const { Moralis, logout, user } = useMoralis();
const { switchNetwork } = useChain();

await Moralis.enableWeb3();
switchNetwork(“0x61”);
1 Like