From 730115ee96e16e10bcc7d413c4e75a771930ac7c Mon Sep 17 00:00:00 2001
From: NestorJMartinez <43479997+NestorJMartinez@users.noreply.github.com>
Date: Tue, 31 May 2022 03:24:46 -0700
Subject: [PATCH] fixed react unmounted warning
---
components/Misc/S3Util.tsx | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/components/Misc/S3Util.tsx b/components/Misc/S3Util.tsx
index 45efcb5..6e5bf9f 100644
--- a/components/Misc/S3Util.tsx
+++ b/components/Misc/S3Util.tsx
@@ -14,9 +14,13 @@ export function S3Image({ S3key, style }: S3ImageProps) {
const [source, setSource] = useState(PLACEHOLDER_IMG_URL);
useEffect(() => {
+ let downloading = true;
getImage(S3key).then((response) => {
- if (response) setSource({ uri: response });
+ if (response && downloading) setSource({ uri: response });
});
+ return () => {
+ downloading = false;
+ };
}, [S3key]);
return ;
@@ -26,9 +30,13 @@ export function S3ImageBackground({ S3key, style }: S3ImageProps) {
const [source, setSource] = useState(PLACEHOLDER_BANNER);
useEffect(() => {
+ let downloading = true;
getImage(S3key).then((response) => {
- if (response) setSource({ uri: response });
+ if (response && downloading) setSource({ uri: response });
});
+ return () => {
+ downloading = false;
+ };
}, [S3key]);
return ;