Skip to content

Commit

Permalink
fix: Update Avatar when src is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Oct 21, 2023
1 parent 3b54fbe commit 2148c63
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/soapbox/components/ui/avatar/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import React, { useState } from 'react';
import React, { useLayoutEffect, useState } from 'react';

import StillImage, { IStillImage } from 'soapbox/components/still-image';

Expand All @@ -21,6 +21,10 @@ const Avatar = (props: IAvatar) => {

const handleLoadFailure = () => setIsAvatarMissing(true);

useLayoutEffect(() => {
setIsAvatarMissing(!src);
}, [src]);

const style: React.CSSProperties = React.useMemo(() => ({
width: size,
height: size,
Expand Down

0 comments on commit 2148c63

Please sign in to comment.