fix back button render jitter
This commit is contained in:
parent
d9dd4bc05b
commit
b9fdbde520
@ -10,7 +10,7 @@ import Price from './price'
|
|||||||
import { useMe } from './me'
|
import { useMe } from './me'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import { signOut } from 'next-auth/react'
|
import { signOut } from 'next-auth/react'
|
||||||
import { useCallback, useEffect, useState } from 'react'
|
import { useCallback, useEffect } from 'react'
|
||||||
import { randInRange } from '../lib/rand'
|
import { randInRange } from '../lib/rand'
|
||||||
import { abbrNum } from '../lib/format'
|
import { abbrNum } from '../lib/format'
|
||||||
import NoteIcon from '../svgs/notification-4-fill.svg'
|
import NoteIcon from '../svgs/notification-4-fill.svg'
|
||||||
@ -31,17 +31,19 @@ function WalletSummary ({ me }) {
|
|||||||
|
|
||||||
function Back () {
|
function Back () {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [show, setShow] = useState()
|
|
||||||
|
|
||||||
useEffect(() => {
|
return router.asPath !== '/' &&
|
||||||
setShow(router.asPath !== '/' &&
|
<a
|
||||||
(typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack))
|
role='button' tabIndex='0' className='nav-link standalone p-0' onClick={() => {
|
||||||
}, [router.asPath])
|
if (typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack) {
|
||||||
|
router.back()
|
||||||
if (show) {
|
} else {
|
||||||
return <a role='button' tabIndex='0' className='nav-link standalone p-0' onClick={() => router.back()}><BackArrow className='theme me-1 me-md-2' width={22} height={22} /></a>
|
router.push('/')
|
||||||
}
|
}
|
||||||
return null
|
}}
|
||||||
|
>
|
||||||
|
<BackArrow className='theme me-1 me-md-2' width={22} height={22} />
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
function NotificationBell () {
|
function NotificationBell () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user