How await account from web3React?

Viewed 34

Code:

const App = () => {
  const { account } = useWeb3React()

  return (
    {account
      ? <Dasboard/>
      : <HomePage/>
    }
  )

}

Issue:

The account does not come immediately, but after about half a second, because of this there is a blinking of the interface. While there is no account, the HomePage component is shown for a second, then the Dashboard is shown. How do I fix this? If account false I always must render HomePage.

1 Answers

you can implement some kind of spinner:


const App = () => {

 if(loading) return <Spinner />

  return (
    {account
      ? <Dasboard/>
      : <HomePage/>
    }
  )

}
Related