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