Skip to content

Commit 107742b

Browse files
authored
1277 react compiler 적용 (#1281)
1 parent 78ed1e3 commit 107742b

34 files changed

Lines changed: 1288 additions & 759 deletions

File tree

.pnp.cjs

Lines changed: 610 additions & 301 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

next.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const nextConfig = {
3232
return config;
3333
},
3434
experimental: {
35+
reactCompiler: true,
3536
workerThreads: false,
3637
},
3738
images: {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@types/react": "^19.2.14",
7171
"@types/react-dom": "^19.2.3",
7272
"@types/react-window": "^1.8.5",
73+
"babel-plugin-react-compiler": "1.0.0",
7374
"dotenv": "^17.2.3",
7475
"eslint": "^9.38.0",
7576
"eslint-config-prettier": "^10.1.8",
@@ -78,7 +79,7 @@
7879
"eslint-plugin-jsx-a11y": "^6.10.2",
7980
"eslint-plugin-prettier": "^5.5.4",
8081
"eslint-plugin-react": "^7.37.5",
81-
"eslint-plugin-react-hooks": "^7.0.1",
82+
"eslint-plugin-react-hooks": "^7.1.1",
8283
"globals": "^16.4.0",
8384
"jest": "^29.7.0",
8485
"next-sitemap": "^4.2.3",

src/components/Articles/LostItemWritePage/components/Calendar/index.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo, useState } from 'react';
1+
import { useState } from 'react';
22
import { cn } from '@bcsdlab/utils';
33
import ChevronLeftIcon from 'assets/svg/Articles/chevron-left.svg';
44
import ChevronRightIcon from 'assets/svg/Articles/chevron-right.svg';
@@ -25,15 +25,11 @@ interface CalendarProps {
2525
export default function Calendar({ selectedDate, setSelectedDate }: CalendarProps) {
2626
const today = new Date();
2727
const [currentMonthDate, setCurrentMonthDate] = useState(selectedDate);
28-
const days = useMemo(
29-
() =>
30-
Array.from({ length: 35 }, (_, i) => {
31-
const startDate = new Date(currentMonthDate.getFullYear(), currentMonthDate.getMonth(), 1);
32-
startDate.setDate(startDate.getDate() - startDate.getDay());
33-
return new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + i);
34-
}),
35-
[currentMonthDate],
36-
);
28+
const days = Array.from({ length: 35 }, (_, i) => {
29+
const startDate = new Date(currentMonthDate.getFullYear(), currentMonthDate.getMonth(), 1);
30+
startDate.setDate(startDate.getDate() - startDate.getDay());
31+
return new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + i);
32+
});
3733

3834
const handleMonthChevronClick = (diff: number) => {
3935
setCurrentMonthDate((prev) => new Date(prev.getFullYear(), prev.getMonth() + diff, 1));

src/components/Articles/hooks/usePagination.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useMemo } from 'react';
21
import useParamsHandler from 'utils/hooks/routing/useParamsHandler';
32

43
const PAGE_LIMIT = 5;
@@ -9,14 +8,14 @@ const usePagination = (totalPageNum: number) => {
98
const raw = Number(params.page) || 1;
109
const currentPage = Math.min(Math.max(raw, 1), Math.max(totalPageNum, 1));
1110

12-
const pages = useMemo(() => {
13-
const half = Math.floor(PAGE_LIMIT / 2);
14-
const maxStart = Math.max(1, totalPageNum - PAGE_LIMIT + 1);
15-
const startPage = Math.min(Math.max(1, currentPage - half), maxStart);
16-
const length = Math.min(PAGE_LIMIT, totalPageNum);
1711

18-
return Array.from({ length }, (_, i) => startPage + i);
19-
}, [currentPage, totalPageNum]);
12+
const half = Math.floor(PAGE_LIMIT / 2);
13+
const maxStart = Math.max(1, totalPageNum - PAGE_LIMIT + 1);
14+
const startPage = Math.min(Math.max(1, currentPage - half), maxStart);
15+
const length = Math.min(PAGE_LIMIT, totalPageNum);
16+
17+
const pages = Array.from({ length }, (_, i) => startPage + i);
18+
2019

2120
const movePage = (target: number | 'prev' | 'next') => {
2221
let nextPage = currentPage;

src/components/Auth/SignupPage/Steps/MobileVerificationStep/index.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/* eslint-disable react-hooks/exhaustive-deps */
21
/* eslint-disable no-restricted-imports */
3-
import { useEffect, useState } from 'react';
2+
import { useEffect, useRef, useState } from 'react';
43
import { isKoinError } from '@bcsdlab/koin';
54
import { useMutation } from '@tanstack/react-query';
65
import { checkPhone, smsSend, smsVerify } from 'api/auth';
@@ -52,6 +51,7 @@ function MobileVerification({ onNext }: MobileVerificationProps) {
5251
const [isVerified, enableVerified] = useBooleanState(false);
5352
const [isCodeCorrect, setCorrect, setIncorrect] = useBooleanState(false);
5453
const [smsSendCountData, setSmsSendCountData] = useState<SmsSendCountData | null>(null);
54+
const verificationMessageTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
5555

5656
const {
5757
isRunning: isTimer,
@@ -65,12 +65,24 @@ function MobileVerification({ onNext }: MobileVerificationProps) {
6565
},
6666
});
6767

68+
const clearVerificationMessageTimer = () => {
69+
if (verificationMessageTimerRef.current) {
70+
clearTimeout(verificationMessageTimerRef.current);
71+
verificationMessageTimerRef.current = null;
72+
}
73+
};
74+
6875
const { mutate: sendSMSToUser } = useMutation({
6976
mutationFn: smsSend,
7077
onSuccess: (data: SmsSendResponse) => {
78+
clearVerificationMessageTimer();
7179
setPhoneMessage({ type: 'success', content: MESSAGES.PHONE.CODE_SENT });
7280
runTimer();
7381
showVerification();
82+
clearVerificationMessageTimer();
83+
verificationMessageTimerRef.current = setTimeout(() => {
84+
setVerificationMessage({ type: 'default', content: MESSAGES.VERIFICATION.DEFAULT });
85+
}, 60000);
7486
setSmsSendCountData({
7587
total_count: data.total_count,
7688
remaining_count: data.remaining_count,
@@ -149,21 +161,20 @@ function MobileVerification({ onNext }: MobileVerificationProps) {
149161
});
150162
};
151163

152-
const isNameAndGenderFilled = name?.trim() && gender?.length > 0;
153-
154-
useEffect(() => {
164+
const resetVerificationState = () => {
165+
clearVerificationMessageTimer();
155166
disableButton();
156167
stopTimer();
157168
setVerificationMessage(null);
158169
setPhoneMessage(null);
159170
setIncorrect();
160-
}, [phoneNumber]);
171+
};
172+
173+
const isNameAndGenderFilled = name?.trim() && gender?.length > 0;
161174

162175
useEffect(() => {
163-
if (timerValue === 120) {
164-
setVerificationMessage({ type: 'default', content: MESSAGES.VERIFICATION.DEFAULT });
165-
}
166-
}, [timerValue]);
176+
return () => clearVerificationMessageTimer();
177+
}, []);
167178

168179
return (
169180
<div className={styles.container}>
@@ -208,6 +219,12 @@ function MobileVerification({ onNext }: MobileVerificationProps) {
208219
render={({ field }) => (
209220
<CustomInput
210221
{...field}
222+
onChange={(e) => {
223+
if (e.target.value !== field.value) {
224+
resetVerificationState();
225+
}
226+
field.onChange(e);
227+
}}
211228
placeholder="- 없이 번호를 입력해 주세요."
212229
isDelete={!isVerified}
213230
message={phoneMessage}

src/components/Auth/SignupPage/Steps/Terms/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use no memo'; //react compiler로 인한 watch 오류 방지
12
import { cn } from '@bcsdlab/utils';
23
import CustomCheckbox from 'components/Auth/SignupPage/components/CustomCheckbox';
34
import { useFormContext } from 'react-hook-form';

src/components/Callvan/components/AddPostForm/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useState } from 'react';
1+
import { useState } from 'react';
22
import { useRouter } from 'next/router';
33
import { cn } from '@bcsdlab/utils';
44
import { CALLVAN_POST_LOCATION_LABEL, CallvanPostLocationType } from 'api/callvan/entity';
@@ -70,22 +70,22 @@ export default function AddPostForm() {
7070
(form.departureType !== 'CUSTOM' || form.departureCustomName.trim() !== '') &&
7171
(form.arrivalType !== 'CUSTOM' || form.arrivalCustomName.trim() !== '');
7272

73-
const handleSwapLocation = useCallback(() => {
73+
const handleSwapLocation = () => {
7474
setForm((prev) => ({
7575
...prev,
7676
departureType: prev.arrivalType,
7777
departureCustomName: prev.arrivalCustomName,
7878
arrivalType: prev.departureType,
7979
arrivalCustomName: prev.departureCustomName,
8080
}));
81-
}, []);
81+
}
8282

83-
const handleParticipantsChange = useCallback((delta: number) => {
83+
const handleParticipantsChange = (delta: number) => {
8484
setForm((prev) => ({
8585
...prev,
8686
maxParticipants: Math.min(11, Math.max(2, prev.maxParticipants + delta)),
8787
}));
88-
}, []);
88+
}
8989

9090
const handleSubmit = () => {
9191
if (!form.departureType || !form.arrivalType || isPending) return;

src/components/Callvan/components/CallvanChatRoom/index.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef, useState, useEffect, useMemo } from 'react';
1+
import { useRef, useState, useEffect } from 'react';
22
import { useRouter } from 'next/router';
33
import { useSuspenseQuery } from '@tanstack/react-query';
44
import { CallvanChatMessage } from 'api/callvan/entity';
@@ -112,15 +112,13 @@ export default function CallvanChatRoom({ postId }: CallvanChatRoomProps) {
112112
}
113113
};
114114

115-
const senderColorMap = useMemo(() => {
116-
const map = new Map<number, number>();
117-
data.messages.forEach((msg) => {
118-
if (!msg.is_mine && !map.has(msg.user_id)) {
119-
map.set(msg.user_id, map.size);
120-
}
121-
});
122-
return map;
123-
}, [data.messages]);
115+
const senderColorMap = new Map<number, number>();
116+
117+
data.messages.forEach((message) => {
118+
if (!message.is_mine && !senderColorMap.has(message.user_id)) {
119+
senderColorMap.set(message.user_id, senderColorMap.size);
120+
}
121+
});
124122

125123
const messageGroups = groupMessagesByDate(data.messages);
126124

src/components/Callvan/components/CallvanFilterPanel/index.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import { useCallback, useEffect, useRef, useState } from 'react';
2-
import {
3-
CallvanAuthor,
4-
CallvanLocation,
5-
CallvanSort,
6-
CallvanStatus,
7-
CALLVAN_LOCATION_LABEL,
8-
} from 'api/callvan/entity';
1+
import { useEffect, useRef, useState } from 'react';
2+
import { CallvanAuthor, CallvanLocation, CallvanSort, CallvanStatus, CALLVAN_LOCATION_LABEL } from 'api/callvan/entity';
93
import SpinIcon from 'assets/svg/Callvan/spin.svg';
104
import CloseIcon from 'assets/svg/close-icon-black.svg';
115
import StatusBadge from 'components/Callvan/components/StatusBadge';
@@ -81,28 +75,28 @@ export default function CallvanFilterPanel({
8175
return () => document.removeEventListener('keydown', handleKeyDown);
8276
}, [isOpen, onClose]);
8377

84-
const toggleStatus = useCallback((value: CallvanStatus) => {
78+
const toggleStatus = (value: CallvanStatus) => {
8579
setLocalStatuses((prev) => {
8680
if (prev.includes(value)) return prev.filter((s) => s !== value);
8781
return [...prev, value];
8882
});
89-
}, []);
83+
};
9084

9185
const toggleDeparture = (value: CallvanLocation) => {
9286
setLocalDepartures((prev) => {
9387
if (prev.includes(value)) return prev.filter((l) => l !== value);
9488
const next = [...prev, value];
9589
return next.length === CALLVAN_FILTER_LOCATIONS.length ? [] : next;
9690
});
97-
}
91+
};
9892

9993
const toggleArrival = (value: CallvanLocation) => {
10094
setLocalArrivals((prev) => {
10195
if (prev.includes(value)) return prev.filter((l) => l !== value);
10296
const next = [...prev, value];
10397
return next.length === CALLVAN_FILTER_LOCATIONS.length ? [] : next;
10498
});
105-
}
99+
};
106100

107101
const handleApply = () => {
108102
onApply({
@@ -191,11 +185,7 @@ export default function CallvanFilterPanel({
191185
<section className={styles.section}>
192186
<h3 className={styles.section__title}>모집 상태</h3>
193187
<div className={styles.section__badges}>
194-
<StatusBadge
195-
label="전체"
196-
isActive={localStatuses.length === 0}
197-
onClick={() => setLocalStatuses([])}
198-
/>
188+
<StatusBadge label="전체" isActive={localStatuses.length === 0} onClick={() => setLocalStatuses([])} />
199189
{STATUS_OPTIONS.map((opt) => (
200190
<StatusBadge
201191
key={opt.value}
@@ -239,11 +229,7 @@ export default function CallvanFilterPanel({
239229
<span className={styles.section__description}>기타 장소는 검색창을 이용해주세요.</span>
240230
</div>
241231
<div className={styles.section__badges}>
242-
<StatusBadge
243-
label="전체"
244-
isActive={localArrivals.length === 0}
245-
onClick={() => setLocalArrivals([])}
246-
/>
232+
<StatusBadge label="전체" isActive={localArrivals.length === 0} onClick={() => setLocalArrivals([])} />
247233
{CALLVAN_FILTER_LOCATIONS.map((loc) => (
248234
<StatusBadge
249235
key={loc}

0 commit comments

Comments
 (0)