Skip to content

Commit

Permalink
fix: 모바일 화면 전환시 현재 선택된 버튼 상태 유실(#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeeZinu committed Jun 19, 2024
1 parent 944a439 commit b2ccaf0
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,29 @@ export default function UserActivityList() {
getNextPageParam: (lastPage) => lastPage.nextCursor ?? undefined,
});

const selectTab = ORDER.PROFILE.filter((i) => i.value === selectedButton);
console.log("selectedButton", typeof selectedButton);
const selectTab = ORDER.PROFILE.filter((i) => i.value === selectedButton) ?? "reviewed";
console.log("selectedButton", selectedButton);

console.log("selectTab", width, selectTab);

console.log("watch(select)", watch("select"));

useEffect(() => {
if (width <= 1023 && watch("select") === undefined) {
if (width <= 1023 && watch("select") === "") {
setSelectedButton("reviewed");
}
if (width <= 1023 && watch("select") !== undefined) {
if (width <= 1023 && watch("select") !== "") {
setSelectedButton(watch("select"));
}

router.push(`${userId}/?${querySelectButton(selectedButton)}`);
}, [selectedButton, watch("select")]);

useEffect(() => {
if (inView && hasNextPage) {
fetchNextPage();
}
router.push(`${userId}/?${querySelectButton(selectedButton)}`);
}, [inView, fetchNextPage, hasNextPage, watch("select"), selectedButton]);
}, [inView, fetchNextPage, hasNextPage]);

const onSelectButtonHandler = (value: string) => {
setSelectedButton(value);
Expand Down

0 comments on commit b2ccaf0

Please sign in to comment.