From cdb8c80a7e00c4a3b9b96995209eea63cd85c201 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa <72977554+Cristhianzl@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:43:24 -0300 Subject: [PATCH] fix: prevent to loop on keys of object profile pictures when It's not loaded yet (#2658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 (use-preload-images.tsx): add null check for profilePictures to prevent errors when profilePictures is undefined Co-authored-by: anovazzi1 --- .../profilePictureChooserComponent/hooks/use-preload-images.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-preload-images.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-preload-images.tsx index 08cedee8b..5e5bb2a77 100644 --- a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-preload-images.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfilePictureForm/components/profilePictureChooserComponent/hooks/use-preload-images.tsx @@ -21,7 +21,7 @@ const usePreloadImages = ( }; useEffect(() => { - if (loading) return; + if (loading || !profilePictures) return; const imageArray: string[] = []; Object.keys(profilePictures).flatMap((folder) =>