Skip to content

Commit

Permalink
fix(SuspensefulImage): fix changing src
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed Jan 17, 2023
1 parent 7501817 commit 9723854
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/custom-components/SuspensefulImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const SuspensefulImage: FC<SuspensefulImageProps> = (props) => {
const [error, setError] = useState(false);

useEffect(() => {
setLoading(true);
setError(false);
const img = new Image();
img.src = props.src || '';
img.addEventListener('load', () => {
Expand All @@ -21,7 +23,7 @@ export const SuspensefulImage: FC<SuspensefulImageProps> = (props) => {
img.addEventListener('error', () => {
setError(true);
});
}, []);
}, [props.src]);

return loading ? (
<div
Expand Down

0 comments on commit 9723854

Please sign in to comment.