Fix "useENSName" Hook (#578)

* Fix "useENSName" Hook

* Check for "stale" in "useENSName" Hook
This commit is contained in:
Paul Razvan Berg 2019-12-31 22:17:10 +02:00 committed by Noah Zinsmeister
parent e00e7af599
commit 701cbde274

@ -146,8 +146,9 @@ export function useENSName(address) {
useEffect(() => {
if (isAddress(address)) {
let stale = false
try {
library.lookupAddress(address).then(name => {
library
.lookupAddress(address)
.then(name => {
if (!stale) {
if (name) {
setENSName(name)
@ -156,9 +157,11 @@ export function useENSName(address) {
}
}
})
} catch {
.catch(() => {
if (!stale) {
setENSName(null)
}
})
return () => {
stale = true