Skip to content

Commit

Permalink
fix: prevent to display a broken favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
helciofranco committed Jan 10, 2025
1 parent 9974a21 commit 7a0b55a
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { Icon } from '@fuel-ui/react';
import { useState } from 'react';

interface DappAvatarProps {
favIconUrl: string | undefined;
title: string | undefined;
}

export const DappAvatar = ({ favIconUrl, title }: DappAvatarProps) => {
if (favIconUrl) {
return <img src={favIconUrl} alt="favicon" />;
const [imageFallback, setImageFallback] = useState(false);

if (favIconUrl && !imageFallback) {
return (
<img
src={favIconUrl}
alt="favicon"
onError={() => {
setImageFallback(true);
}}
/>
);
}

if (title) {
Expand Down

0 comments on commit 7a0b55a

Please sign in to comment.