feat: Suppress the account modal after connect (#3848)

fix: Suppress the account modal after connect
This commit is contained in:
Clayton Lin 2022-06-01 10:01:11 -05:00 committed by GitHub
parent caa0a2967d
commit fd0489e654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -127,7 +127,7 @@ export default function WalletModal({
ENSName?: string
}) {
// important that these are destructed from the account-specific web3-react context
const { active, account, connector, activate, error } = useWeb3React()
const { account, connector, activate, error } = useWeb3React()
const [walletView, setWalletView] = useState(WALLET_VIEWS.ACCOUNT)
const previousWalletView = usePrevious(walletView)
@ -161,13 +161,6 @@ export default function WalletModal({
}, [walletModalOpen, resetAccountView])
// close modal when a connection is successful
const activePrevious = usePrevious(active)
const connectorPrevious = usePrevious(connector)
useEffect(() => {
if (walletModalOpen && ((active && !activePrevious) || (connector && connector !== connectorPrevious && !error))) {
setWalletView(WALLET_VIEWS.ACCOUNT)
}
}, [setWalletView, active, error, connector, walletModalOpen, activePrevious, connectorPrevious])
const tryActivation = async (connector: AbstractConnector | undefined) => {
let name = ''