Commit ef843243 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: missing token img (#3727)

parent 71aebf33
...@@ -21,18 +21,21 @@ function TokenImg({ token, ...rest }: TokenImgProps) { ...@@ -21,18 +21,21 @@ function TokenImg({ token, ...rest }: TokenImgProps) {
const srcs = useCurrencyLogoURIs(tokenInfo) const srcs = useCurrencyLogoURIs(tokenInfo)
const [attempt, setAttempt] = useState(0) const [attempt, setAttempt] = useState(0)
const onError = useCallback((e) => {
if (e.target.src) badSrcs.add(e.target.src)
setAttempt((attempt) => ++attempt)
}, [])
const src = useMemo(() => { const src = useMemo(() => {
// Trigger a re-render when an error occurs. // Trigger a re-render when an error occurs.
void attempt void attempt
return srcs.find((src) => !badSrcs.has(src)) return srcs.find((src) => !badSrcs.has(src))
}, [attempt, srcs]) }, [attempt, srcs])
const onError = useCallback(
(e) => {
if (src) badSrcs.add(src)
setAttempt((attempt) => ++attempt)
},
[src]
)
console.log('zzmp', tokenInfo.symbol, src)
if (!src) return <MissingToken color="secondary" {...rest} /> if (!src) return <MissingToken color="secondary" {...rest} />
const alt = tokenInfo.name || tokenInfo.symbol const alt = tokenInfo.name || tokenInfo.symbol
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment