fix ssr and client side rendering difference warnings

This commit is contained in:
keyan 2023-06-12 17:59:53 -05:00
parent ef533d41a6
commit 6ed2c87c49
1 changed files with 9 additions and 3 deletions

View File

@ -29,9 +29,15 @@ function WalletSummary ({ me }) {
function Back () {
const router = useRouter()
if (typeof window !== 'undefined' && router.asPath !== '/' &&
(typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack)) {
return <a role='button' tabindex='0' className='nav-link p-0' onClick={() => router.back()}><BackArrow className='theme standalone mr-1 mr-md-2' width={22} height={22} /></a>
const [show, setShow] = useState()
useEffect(() => {
setShow(typeof window !== 'undefined' && router.asPath !== '/' &&
(typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack))
}, [router.asPath])
if (show) {
return <a role='button' tabIndex='0' className='nav-link standalone p-0' onClick={() => router.back()}><BackArrow className='theme mr-1 mr-md-2' width={22} height={22} /></a>
}
return null
}