Skip to content

Commit 8b1447f

Browse files
committed
feat : 알림구독 테스트용 App.tsx에 훅 호출한 코드
1 parent cdc0183 commit 8b1447f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Route, Routes } from 'react-router';
22

3+
import { useServerSentEvents } from './hooks/useServerSentEvents';
34
import useViewport from './hooks/useViewport';
45
import Layout from './layouts/Layout';
56
import MobileLayout from './layouts/MobileLayout';
@@ -27,6 +28,7 @@ import WritePage from './pages/Write';
2728

2829
const App = () => {
2930
useViewport();
31+
useServerSentEvents();
3032

3133
return (
3234
<Routes>

src/hooks/useServerSentEvents.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export const useServerSentEvents = () => {
3030
console.log('알림 전송');
3131
};
3232

33-
// sourceRef.current.addEventListener('notification', (event) => {
34-
// console.log(event);
35-
// console.log('알림 전송 dd');
36-
// });
33+
sourceRef.current.addEventListener('notification', (event) => {
34+
console.log(event);
35+
console.log('알림 전송 dd');
36+
});
3737

3838
sourceRef.current.onerror = (error) => {
3939
console.log(error);

src/pages/Notifications/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ import { useNavigate } from 'react-router';
33

44
import { getTimeLines, patchReadNotification, patchReadNotificationAll } from '@/apis/notification';
55
import PageTitle from '@/components/PageTitle';
6-
import { useServerSentEvents } from '@/hooks/useServerSentEvents';
76

87
import NotificationItem from './components/NotificationItem';
98
import WarningModal from './components/WarningModal';
109

1110
const NotificationsPage = () => {
12-
useServerSentEvents();
13-
1411
const navigate = useNavigate();
1512

1613
const [noti, setNoti] = useState<Noti[]>([]);
@@ -19,6 +16,7 @@ const NotificationsPage = () => {
1916

2017
const [adminText, setAdmintext] = useState<string>('');
2118

19+
// MEMO : 편지 데이터 전송중 데이터도 추가될건데 나중에 데이터 추가되면 코드 업데이트 하긔
2220
const handleClickItem = (alarmType: string, content?: string | number) => {
2321
if (alarmType === 'LETTER') {
2422
navigate(`/letter/${content}`);

0 commit comments

Comments
 (0)