From 80ff3827dcf53be27eb7bd35ee22c68149e0cacb Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:14:20 -0800 Subject: [PATCH] Use functional update in useEffect From react-hooks/exhaustive-deps warning: React Hook useEffect has missing dependencies: 'getGroupLogo' and 'logo'. Either include them or remove the dependency array. You can also do a functional update 'setLogo(l => ...)' if you only need 'logo' in the 'setLogo' call --- static-site/src/components/Groups/edit-logo-form.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static-site/src/components/Groups/edit-logo-form.jsx b/static-site/src/components/Groups/edit-logo-form.jsx index 5ddf45953..3db977196 100644 --- a/static-site/src/components/Groups/edit-logo-form.jsx +++ b/static-site/src/components/Groups/edit-logo-form.jsx @@ -13,7 +13,7 @@ const EditLogoForm = ({ groupName, createErrorMessage, clearErrorMessage }) => { useEffect(() => { const setCurrentLogo = async () => { const currentLogo = await getGroupLogo(); - if (!cleanUp) setLogo({ ...logo, current: currentLogo }); + if (!cleanUp) setLogo(l => ({ ...l, current: currentLogo })); } let cleanUp = false;