Fix "useENSName" Hook (#578)
* Fix "useENSName" Hook * Check for "stale" in "useENSName" Hook
This commit is contained in:
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
|
||||
|
Loading…
Reference in New Issue
Block a user