Skip to content

Commit

Permalink
Use functional update in useEffect
Browse files Browse the repository at this point in the history
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
  • Loading branch information
victorlin committed Jan 10, 2024
1 parent 11f6704 commit 80ff382
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion static-site/src/components/Groups/edit-logo-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 80ff382

Please sign in to comment.