diff --git a/package.json b/package.json index 2ea29b81..1ce70a28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yearn-finance/web-lib", - "version": "3.0.137", + "version": "3.0.139", "main": "./dist/index.js", "types": "./dist/index.d.js", "files": [ diff --git a/src/components/LogoPopover.tsx b/src/components/LogoPopover.tsx index 5fe0277e..7dfe6500 100644 --- a/src/components/LogoPopover.tsx +++ b/src/components/LogoPopover.tsx @@ -1,6 +1,5 @@ import {cloneElement, useMemo, useState} from 'react'; import Link from 'next/link'; -import {useRouter} from 'next/router'; import {motion} from 'framer-motion'; import {cl} from '@builtbymom/web3/utils'; import {Popover, Transition} from '@headlessui/react'; @@ -38,8 +37,6 @@ function MotionDiv({animate, name, children}: TMotionDiv): ReactElement { } function Logo(): ReactElement { - const {pathname} = useRouter(); - const currentHost = useMemo(() => { if (typeof window === 'undefined') { return 'yearn.fi'; @@ -48,6 +45,14 @@ function Logo(): ReactElement { // eslint-disable-next-line react-hooks/exhaustive-deps }, [typeof window]); + const pathname = useMemo(() => { + if (typeof window === 'undefined') { + return '/'; + } + return window.location.pathname; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [typeof window]); + const isYearnFi = useMemo(() => { return currentHost === 'yearn.fi' || currentHost.includes('localhost:'); }, [currentHost]); @@ -80,12 +85,27 @@ function Logo(): ReactElement { export function LogoPopover(): ReactElement { const [isShowing, set_isShowing] = useState(false); - const router = useRouter(); + + const currentHost = useMemo(() => { + if (typeof window === 'undefined') { + return 'yearn.fi'; + } + return window.location.host; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [typeof window]); + + const isYearnFi = useMemo(() => { + return currentHost === 'yearn.fi' || currentHost.includes('localhost:'); + }, [currentHost]); const currentApp = useMemo(() => { - const pageURI = router.pathname.toLowerCase(); - return Object.values(APPS).find(({host}): boolean => pageURI.includes(host)) || APPS.Vaults; - }, [router]); + return Object.values(APPS).find(({host}): boolean => { + if (isYearnFi) { + return window.location.pathname.includes(host); + } + return currentHost.includes(host); + }); + }, [currentHost, isYearnFi]); return ( <>