From 135f20a4d312bfae7e123d6b37f11b6a52e1b837 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Wed, 10 Jul 2024 00:29:48 +0700 Subject: [PATCH] Fix image modal --- src/components/extensions/image/ImageModal.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/extensions/image/ImageModal.tsx b/src/components/extensions/image/ImageModal.tsx index 8f71ef12c..3963c2141 100644 --- a/src/components/extensions/image/ImageModal.tsx +++ b/src/components/extensions/image/ImageModal.tsx @@ -222,9 +222,12 @@ function ImageUpload({ initialImage, setUploadedImageLink }: ImageUploadProps) { setImageUrl('')} src={imageUrl} - onLoad={() => - setUploadedImageLink((prev) => ({ ...prev, loadedLink: imageUrl })) - } + onLoad={() => { + // To prevent this called first before the useEffect, which causes image rendered, but the link is null + setTimeout(() => { + setUploadedImageLink((prev) => ({ ...prev, loadedLink: imageUrl })) + }) + }} /> ) }