From 806ad2c6a222d33a2a697c3b31f4f067826ffd5d Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 12 Oct 2023 23:19:48 +0800 Subject: [PATCH] Fix media re-rendering due to url object keep being recreated --- src/components/compose.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index 570f1395..881c55bc 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -1477,7 +1477,10 @@ function MediaAttachment({ }) { const supportsEdit = supports('@mastodon/edit-media-attributes'); const { type, id, file } = attachment; - const url = file ? URL.createObjectURL(file) : attachment.url; + const url = useMemo( + () => (file ? URL.createObjectURL(file) : attachment.url), + [file, attachment.url], + ); console.log({ attachment }); const [description, setDescription] = useState(attachment.description); const suffixType = type.split('/')[0];