From c938541453b0e7875a2b90b073f5781311af7cc2 Mon Sep 17 00:00:00 2001
From: developersihyeon <139722653+developersihyeon@users.noreply.github.com>
Date: Fri, 11 Oct 2024 14:46:29 +0900
Subject: [PATCH] =?UTF-8?q?refactor=20::=20=EC=BD=98=EC=86=94=20=EC=98=A4?=
=?UTF-8?q?=EB=A5=98=20=EC=A0=9C=EA=B1=B0=20#22?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../common/FallbackSkeleton/index.tsx | 2 +-
.../HomeScheduleSideBarHeaderDropdown.tsx | 9 +++--
src/hooks/schedule/useHomeSidebarSchedule.ts | 34 +++++++++----------
src/index.tsx | 2 +-
4 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/src/components/common/FallbackSkeleton/index.tsx b/src/components/common/FallbackSkeleton/index.tsx
index c3ea37a..7d24495 100644
--- a/src/components/common/FallbackSkeleton/index.tsx
+++ b/src/components/common/FallbackSkeleton/index.tsx
@@ -5,7 +5,7 @@ const FallbackSkeleton = () => {
<>
{Array.from({ length: 6 }).map((_, idx) => (
-
+
))}
>
diff --git a/src/components/home/HomeScheduleSideBar/HomeScheudleSideBarHeader/HomeScheduleSideBarHeaderDropdown/HomeScheduleSideBarHeaderDropdown.tsx b/src/components/home/HomeScheduleSideBar/HomeScheudleSideBarHeader/HomeScheduleSideBarHeaderDropdown/HomeScheduleSideBarHeaderDropdown.tsx
index 8b4ad34..8a82efc 100644
--- a/src/components/home/HomeScheduleSideBar/HomeScheudleSideBarHeader/HomeScheduleSideBarHeaderDropdown/HomeScheduleSideBarHeaderDropdown.tsx
+++ b/src/components/home/HomeScheduleSideBar/HomeScheudleSideBarHeader/HomeScheduleSideBarHeaderDropdown/HomeScheduleSideBarHeaderDropdown.tsx
@@ -19,18 +19,17 @@ const HomeScheduleSideBarHeaderDropdown = () => {
return (
setFold((prev) => !prev)}
- >
+ onClick={() => setFold((prev) => !prev)}>
{classificationKeyword}
{!fold && (
- {HOME_SCHEDULE_SIDE_BAR_HEADER_DROPDOWN_ITEMS.map((item) => (
+ {HOME_SCHEDULE_SIDE_BAR_HEADER_DROPDOWN_ITEMS.map((item, idx) => (
setClassificationKeyword(item)}
- >
+ key={idx}>
{item}
))}
@@ -40,4 +39,4 @@ const HomeScheduleSideBarHeaderDropdown = () => {
);
};
-export default HomeScheduleSideBarHeaderDropdown;
+export default HomeScheduleSideBarHeaderDropdown;
\ No newline at end of file
diff --git a/src/hooks/schedule/useHomeSidebarSchedule.ts b/src/hooks/schedule/useHomeSidebarSchedule.ts
index d6f0673..9f2bbdb 100644
--- a/src/hooks/schedule/useHomeSidebarSchedule.ts
+++ b/src/hooks/schedule/useHomeSidebarSchedule.ts
@@ -1,5 +1,5 @@
import dayjs from "dayjs";
-import { useEffect, useState } from "react";
+import { useCallback, useEffect, useState } from "react";
import { useRecoilValue } from "recoil";
import { useGetMember } from "../../queries/member/member.query";
import { useGetSchedulesByDate } from "../../queries/schedule/schedule.query";
@@ -20,21 +20,21 @@ const useHomeSidebarSchedule = () => {
{ suspense: true },
);
- const loadMyGradeSchedules = () => {
- setSchedules(
- schedulesData?.data.filter(
- (schedule) =>
- schedule.targetGrades[0].indexOf(String(memberData?.data.student.grade)) > -1 ||
- schedule.targetGrades[0] === "전교생",
- )!,
- );
- };
-
- const loadAllSchedules = () => {
- setSchedules(schedulesData!.data);
- };
+ const handleSchedules = useCallback((scope: string) => {
+ const loadMyGradeSchedules = () => {
+ setSchedules(
+ schedulesData?.data.filter(
+ (schedule) =>
+ schedule.targetGrades[0].indexOf(String(memberData?.data.student.grade)) > -1 ||
+ schedule.targetGrades[0] === "전교생",
+ )!,
+ );
+ };
+
+ const loadAllSchedules = () => {
+ setSchedules(schedulesData!.data);
+ };
- const handleSchedules = (scope: string) => {
setSchedules([]);
switch (scope) {
@@ -50,13 +50,13 @@ const useHomeSidebarSchedule = () => {
loadAllSchedules();
break;
}
- };
+ }, [memberData?.data.student.grade, schedulesData]);
useEffect(() => {
if (schedulesData?.data) {
handleSchedules(classificationKeyword);
}
- }, [schedulesData?.data, classificationKeyword]);
+ }, [schedulesData?.data, classificationKeyword, handleSchedules]);
return {
schedules,
diff --git a/src/index.tsx b/src/index.tsx
index cfefb00..34c2ef5 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -15,4 +15,4 @@ root.render(
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
-reportWebVitals();
+reportWebVitals();
\ No newline at end of file