fix: wait to render Landing content until checking wallet cache (#5729)
* fix: wait to render Landing content until checking wallet cache * use state
This commit is contained in:
parent
a2c6d3f475
commit
c8086e3c76
@ -3,7 +3,7 @@ import { BrowserEvent, ElementName, EventName, PageName } from '@uniswap/analyti
|
||||
import { BaseButton } from 'components/Button'
|
||||
import { LandingRedirectVariant, useLandingRedirectFlag } from 'featureFlags/flags/landingRedirect'
|
||||
import Swap from 'pages/Swap'
|
||||
import { useEffect } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { Link as NativeLink } from 'react-router-dom'
|
||||
import { useAppSelector } from 'state/hooks'
|
||||
@ -178,12 +178,19 @@ export default function Landing() {
|
||||
}
|
||||
}, [])
|
||||
|
||||
const [showContent, setShowContent] = useState(false)
|
||||
const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
|
||||
const landingRedirectFlag = useLandingRedirectFlag()
|
||||
const navigate = useNavigate()
|
||||
useEffect(() => {
|
||||
if (selectedWallet && landingRedirectFlag === LandingRedirectVariant.Enabled) {
|
||||
if (selectedWallet) {
|
||||
if (landingRedirectFlag === LandingRedirectVariant.Enabled) {
|
||||
navigate('/swap')
|
||||
} else {
|
||||
setShowContent(true)
|
||||
}
|
||||
} else {
|
||||
setShowContent(true)
|
||||
}
|
||||
}, [navigate, selectedWallet, landingRedirectFlag])
|
||||
|
||||
@ -191,6 +198,7 @@ export default function Landing() {
|
||||
|
||||
return (
|
||||
<Trace page={PageName.LANDING_PAGE} shouldLogImpression>
|
||||
{showContent && (
|
||||
<PageContainer>
|
||||
<TraceEvent
|
||||
events={[BrowserEvent.onClick]}
|
||||
@ -221,6 +229,7 @@ export default function Landing() {
|
||||
</ActionsContainer>
|
||||
</ContentContainer>
|
||||
</PageContainer>
|
||||
)}
|
||||
</Trace>
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user