Skip to content

Commit 223365b

Browse files
authored
Merge pull request #314 from prgrms-web-devcourse-final-project/refactor/remove-scroll-store
[refactor] useScrollStore 전역 상태 제거 및 관련 로직 정리
2 parents 38f38e7 + e6368b1 commit 223365b

File tree

3 files changed

+0
-32
lines changed

3 files changed

+0
-32
lines changed

src/pages/chat/ChatRoom.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { useEffect, useRef, useState } from 'react';
77
import { MAX_CHAT_MESSAGE_LENGTH } from '@/constants';
88
import { loadChatHistoryDev, loadChatRoomDetail } from '@/apis/chat';
99
import { useAuthStore } from '@/store/authStore';
10-
import { useScrollStore } from '@/store/scrollStore';
1110
import { useChatStore } from '@/store/chatStore';
1211
import { useSheetStore } from '@/store/sheetStore';
1312

@@ -52,18 +51,8 @@ export default function ChatRoom({}: ChatRoomProps) {
5251
const [isMobile, setIsMobile] = useState(false);
5352
const textareaRef = useRef<HTMLTextAreaElement | null>(null);
5453

55-
const { scrollContainerRefCurrent } = useScrollStore();
56-
5754
const [chatDisabled, setChatDisabled] = useState(false);
5855

59-
// 최신 메시지로 스크롤
60-
useEffect(() => {
61-
if (scrollContainerRefCurrent) {
62-
// console.log(scrollContainerRefCurrent);
63-
scrollContainerRefCurrent.scrollTop = scrollContainerRefCurrent.scrollHeight;
64-
}
65-
}, [messages, scrollContainerRefCurrent]);
66-
6756
const MAX_LINES = 8;
6857

6958
const [timeLeft, setTimeLeft] = useState<number>(0);

src/pages/home/Home.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ import { useMusicCardStore } from '@/store/MusicCardStore';
1313
import InfoMessage from '@/components/InfoMessage';
1414
import LoadingMini from '@/components/loading/LoadingMini';
1515
import Loading from '@/components/loading/Loading';
16-
import { useScrollStore } from '@/store/scrollStore';
1716

1817
function Home() {
19-
const { scrollContainerRefCurrent } = useScrollStore();
2018
const { isMusicSheetOpen, openSheet, closeAllSheets } = useSheetStore(); // 모달 시트
2119
const { selectedPostMusic, clearPostMusic } = useMusicCardStore(); // 선택된 음악
2220

@@ -104,14 +102,6 @@ function Home() {
104102
}
105103
}, [searchText]);
106104

107-
//홈 이동 시 스크롤 제일 위로
108-
useEffect(() => {
109-
if (scrollContainerRefCurrent) {
110-
// // console.log(scrollContainerRefCurrent);
111-
scrollContainerRefCurrent.scrollTop = 0; // 제일 위로 스크롤
112-
}
113-
}, [scrollContainerRefCurrent]);
114-
115105
return (
116106
<div className="flex flex-col w-full gap-5 mt-5">
117107
<SearchBar

src/store/scrollStore.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)