From 7f0d3870b2a10134c0912ef0188b665c3a3ad4d2 Mon Sep 17 00:00:00 2001 From: Lee sang Yeop Date: Sun, 8 Oct 2023 17:07:17 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EC=B1=84=EB=84=90=20=EB=B3=B4=EB=93=9C?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=95=88=EB=90=98=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sidebar/BoardBar/BoardBody.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Sidebar/BoardBar/BoardBody.tsx b/src/components/Sidebar/BoardBar/BoardBody.tsx index be89ecc..2dd2aea 100644 --- a/src/components/Sidebar/BoardBar/BoardBody.tsx +++ b/src/components/Sidebar/BoardBar/BoardBody.tsx @@ -54,7 +54,7 @@ const postData = async (channelLink: string) => { const BoardBody = ({ channelLink }: Props) => { const [selected, setSelected] = useState(''); - const [boards, setBoards] = useState(); + const [boards, setBoards] = useState([]); const router = useRouter(); const { data, isSuccess } = useQuery(['getBoardLists', channelLink], () => @@ -89,7 +89,7 @@ const BoardBody = ({ channelLink }: Props) => { boardTitle: res.boardTitle, boardIndex: res.boardIndex, }; - setBoards([...boards, newBoard]); + setBoards((prevBoards) => [...prevBoards, newBoard]); selectBoardId(newBoard.boardId); handleBoard(channelLink, newBoard.boardId, res.boardTitle); }; @@ -126,19 +126,19 @@ const BoardBody = ({ channelLink }: Props) => { useEffect(() => { const lastVisitBoardId = lastVisitedBoardIdLists[channelLink]?.boardId; - if (isSuccess) setBoards(data.channelBoardLoadDtdList); + if (data) setBoards(data.channelBoardLoadDtdList); if (lastVisitBoardId) { selectBoardId(lastVisitBoardId); return; } - if (isSuccess) { + if (data) { const tmpBoards = data.channelBoardLoadDtdList; selectBoardId(tmpBoards[0].boardId); handleBoard(channelLink, tmpBoards[0].boardId, tmpBoards[0].boardTitle); } - }, [channelLink, isSuccess]); + }, [channelLink, data]); return (