Skip to content

Commit

Permalink
[FE] FIX: device 모드일 때 토글을 두번 클릭해야 모드가 바뀌는 버그 해결 #1649
Browse files Browse the repository at this point in the history
  • Loading branch information
gykoh42 committed Oct 22, 2024
1 parent 547fe37 commit abbdaff
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions frontend/src/Cabinet/components/Common/DarkModeToggleSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,22 @@ const DarkModeToggleSwitch = ({ id }: { id: string }) => {
}, [displayStyleType]);

const handleToggleChange = useCallback(() => {
const newToggleType =
displayStyleToggle === DisplayStyleToggleType.LIGHT
? DisplayStyleToggleType.DARK
: DisplayStyleToggleType.LIGHT;
let newToggleType;
if (displayStyleToggle === DisplayStyleToggleType.DEVICE) {
newToggleType =
displayStyleType === DisplayStyleType.LIGHT
? DisplayStyleToggleType.DARK
: DisplayStyleToggleType.LIGHT;
} else {
newToggleType =
displayStyleToggle === DisplayStyleToggleType.LIGHT
? DisplayStyleToggleType.DARK
: DisplayStyleToggleType.LIGHT;
}

localStorage.setItem("display-style-toggle", newToggleType);
setDisplayStyleToggle(newToggleType);
}, [displayStyleToggle]);
}, [displayStyleType]);

return (
<ToggleWrapperStyled>
Expand Down

0 comments on commit abbdaff

Please sign in to comment.