-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(frontend): Add fallback for image load error on Avatar #9501
fix(frontend): Add fallback for image load error on Avatar #9501
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! i have some minor code style suggestions otherwise this is good to go! thanks for this
const avatar = | ||
photoUrl && photoUrl !== '' ? <AvatarStyled src={photoUrl} style={style} size={size} /> : avatarWithDefault; | ||
photoUrl && photoUrl !== '' && !imageError ? <AvatarStyled src={photoUrl} style={style} size={size} onError={() => onErrorHandling()} /> : avatarWithDefault; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's unnecessary to have an arrow function here, you could just write onError={onErrorHandling}
I would also rename this from onErrorHandling
to something like handleImageError
to be a little more clear, verbose, and consistent with our function names
…hub.com/ingthorb/datahub into add_backup_photo_for_avatar_picture_url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
0b66e5e
into
datahub-project:master
Description
This is a fix for when using the CorpUser Image URL and there is an error when fetching the image. Before the error was not handled and showed an empty space where the image should be but now with the onError function from Ant we have a fallback Avatar Style which is the default one.
Checklist