diff --git a/src/sections/analysis/panelToolbar/flipBoardButton.tsx b/src/sections/analysis/panelToolbar/flipBoardButton.tsx index e69c77e..dbd6e6d 100644 --- a/src/sections/analysis/panelToolbar/flipBoardButton.tsx +++ b/src/sections/analysis/panelToolbar/flipBoardButton.tsx @@ -2,24 +2,25 @@ import { useSetAtom } from "jotai"; import { boardOrientationAtom } from "../states"; import { IconButton, Tooltip } from "@mui/material"; import { Icon } from "@iconify/react"; +import { useEffect } from "react"; export default function FlipBoardButton() { const setBoardOrientation = useSetAtom(boardOrientationAtom); - useEffect(() => { - const onKeyDown = (e: KeyboardEvent) => { - if (e.key === "f") { - setBoardOrientation((prev) => !prev); - } - }; + useEffect(() => { + const onKeyDown = (e: KeyboardEvent) => { + if (e.key === "f") { + setBoardOrientation((prev) => !prev); + } + }; - window.addEventListener("keydown", onKeyDown); + window.addEventListener("keydown", onKeyDown); + + return () => { + window.removeEventListener("keydown", onKeyDown); + }; + }, [setBoardOrientation]); - return () => { - window.removeEventListener("keydown", onKeyDown); - }; - }, []); - return (