diff --git a/src/helpers/NetworkMonitor.tsx b/src/helpers/NetworkMonitor.tsx index b265807b3..be326189c 100644 --- a/src/helpers/NetworkMonitor.tsx +++ b/src/helpers/NetworkMonitor.tsx @@ -5,31 +5,31 @@ import { useEffect } from 'react' import { getOceanConfig } from './wrapRootElement' export function NetworkMonitor() { - const { connect, web3Provider } = useOcean() + const { connect, web3Provider } = useOcean() - const handleNetworkChanged = (chainId: number) => { - // temp hack - let network = '' - switch (chainId) { - case 1: { - network = 'mainnet' - } - case 4: { - network = 'rinkeby' - } - } - const config = getOceanConfig(network) - connect(config) + const handleNetworkChanged = (chainId: number) => { + // temp hack + let network = '' + switch (chainId) { + case 1: { + network = 'mainnet' + } + case 4: { + network = 'rinkeby' + } } - useEffect(() => { - if (!web3Provider) return + const config = getOceanConfig(network) + connect(config) + } + useEffect(() => { + if (!web3Provider) return - web3Provider.on('chainChanged', handleNetworkChanged) + web3Provider.on('chainChanged', handleNetworkChanged) - return () => { - web3Provider.removeListener('chainChanged', handleNetworkChanged) - } - }, [web3Provider]) + return () => { + web3Provider.removeListener('chainChanged', handleNetworkChanged) + } + }, [web3Provider]) - return (<>) + return <> } diff --git a/src/helpers/wrapRootElement.tsx b/src/helpers/wrapRootElement.tsx index 20399e7fb..63cfacbbe 100644 --- a/src/helpers/wrapRootElement.tsx +++ b/src/helpers/wrapRootElement.tsx @@ -25,7 +25,7 @@ export default function wrapRootElement({ initialConfig={oceanInitialConfig} web3ModalOpts={web3ModalOpts} > - + {element} )