Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ ๐Ÿ“š Library ] ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฆฌํŒฉํ† ๋ง #155

Merged
merged 29 commits into from
Feb 12, 2023

Conversation

pinktopaz
Copy link
Contributor

@pinktopaz pinktopaz commented Feb 9, 2023

๐Ÿ”ฅ Related Issues

resolved #145

๐Ÿ’œ ์ž‘์—… ๋‚ด์šฉ + ๐Ÿ”ฅ ํŠธ๋Ÿฌ๋ธ”์ŠˆํŒ…

  • ~ ์„œ๋ฒ„ํ†ต์‹  useSWRInfinite ์ ์šฉ (๊ฐ€๋กœ, ์„ธ๋กœ ๋ชจ๋‘)
// โœ… ์„ธ๋กœ ๋ฌดํ•œ์Šคํฌ๋กค (useGetAllVoteInfo.tsx)
const getKey = (prevLastDate: number, allVoteInfo: AxiosResponse<EndedVoteInfo>) => {
  if (prevLastDate === 0) return `/vote/library/scroll/all?flag=${prevLastDate}`;
  if (allVoteInfo) return `/vote/library/scroll/all?flag=${allVoteInfo.data.dates[allVoteInfo.data.dates.length - 1]}`;
  return null;
};

export const useGetAllVoteInfo = () => {
  const { data, isLoading, error, size, setSize } = useSWRInfinite<AxiosResponse<EndedVoteInfo>>(
    getKey,
    picmeGetFetcher,
    {
      errorRetryCount: 3,
    },
  );

  const parseResultList = data?.map((item) => item.data.dates).flat();

  return {
    allVoteInfoList: { dateList: parseResultList ? parseResultList : [] },
    isLoading,
    isError: error,
    size,
    setSize,
  };
};

โ†’ ์ฒ˜์Œ์—๋Š” SWR๋งŒ ์ ์šฉํ–ˆ์—ˆ๋Š”๋ฐ, ์„œ๋ฒ„ ํ†ต์‹  ๊ฒฐ๊ณผ๊ฐ€ ์ข…์ข… null๋กœ ์™€์„œ ํ™”๋ฉด์— ํˆฌํ‘œ๊ฐ€ ๋ Œ๋”๋ง๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.
@Happhee ๋•๋ถ„์— useSWRInfinite๋ฅผ ์ ์šฉํ–ˆ๊ณ , ํ•ด๋‹น ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.
userSWRInfinite์— ํฌํ•จ๋œ ํ•จ์ˆ˜ getKey๋Š” ํ˜„์žฌ ํŽ˜์ด์ง€์˜ ์ธ๋ฑ์Šค์™€ ์ด์ „ ํŽ˜์ด์ง€์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›๊ธฐ ๋•Œ๋ฌธ์— ์ฒซ ํ˜ธ์ถœ๊ณผ ์ดํ›„ ํ˜ธ์ถœ, ๊ทธ๋ฆฌ๊ณ  ๋งˆ์ง€๋ง‰ ํ˜ธ์ถœ์— ๋Œ€ํ•œ ๋ถ„๊ธฐ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

  • ~ ๊ฐ€๋กœ, ์„ธ๋กœ ์Šคํฌ๋กค ์„œ๋ฒ„ ํ†ต์‹  ๋ณ€๊ฒฝ์‚ฌํ•ญ ๋ฐ˜์˜
 const { data, isLoading, error, size, setSize } = useSWRInfinite<AxiosResponse<VoteInfo[]>>(
    (idx: number, monthlyVoteInfo: AxiosResponse<VoteInfo[]>) => {
      if (idx === 0) return `/vote/library/scroll/month?flag=${0}&date=${date}`;
      if (monthlyVoteInfo.data[0])
        return `/vote/library/scroll/month?flag=${
          monthlyVoteInfo.data[monthlyVoteInfo.data.length - 1].id
        }&date=${date}`;
      return null;
    },

โ†’ ๊ธฐ์กด : ์„ธ๋กœ API๋ฅผ ํ˜ธ์ถœํ–ˆ์„ ๋•Œ ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฐ€๋กœ ๋ฌดํ•œ์Šคํฌ๋กค์˜ ์ดˆ๊ธฐ ๋ฐ์ดํ„ฐ 5๊ฐœ๊ฐ€ ์„ธํŒ…์ด ๋˜๊ณ , ๊ทธ ๋‹ค์Œ๋ถ€ํ„ฐ ์ƒˆ๋กœ ๊ฐ€๋กœ ๋ฌดํ•œ์Šคํฌ๋กค API๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ํ˜•์‹
โ†’ ํ˜„์žฌ : ์„ธ๋กœ API์—์„œ ์ดˆ๊ธฐ ๋ฐ์ดํ„ฐ 5๊ฐœ๋ฅผ ๋ณด๋‚ด์ฃผ์ง€ ์•Š๊ณ  ๋‚ ์งœ๋งŒ ์ „๋‹ฌํ•ด์ฃผ๊ณ , ๊ฐ€๋กœ ๋ฌดํ•œ์Šคํฌ๋กค API์—์„œ ์ฒ˜์Œ์—๋Š” flag=0๋ฅผ ๋ณด๋‚ด์„œ ์ดˆ๊ธฐ๋ฐ์ดํ„ฐ 5๊ฐœ๋ฅผ ๋ฐ›์•„์˜ค๋Š” ํ˜•์‹

SWR์„ ์ ์šฉํ•˜๊ธฐ ์ „์—๋Š” ์„ธ๋กœ ๋ฌดํ•œ์Šคํฌ๋กค ์ปดํฌ๋„ŒํŠธ์—์„œ date๋ฅผ props๋กœ ๋„˜๊ฒจ์ฃผ์–ด ๊ฐ€๋กœ ๋ฌดํ•œ์Šคํฌ๋กค API์˜ ์ธ์ž๋กœ ๋„ฃ์–ด์ฃผ์—ˆ๋Š”๋ฐ, SWR์„ ์ ์šฉํ•˜๋‹ˆ props๋กœ ๋„˜๊ฒจ์ค€ ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์–ด๋ ค์›Œ์ ธ์„œ ์–ด๋–ป๊ฒŒ ๋‚ ์งœ๋ฅผ ์ธ์ž๋กœ ๋„ฃ์–ด์ค„ ์ˆ˜ ์žˆ์„์ง€ ๊ณ ๋ฏผํ–ˆ์Šต๋‹ˆ๋‹ค.
โ†’ @Happhee ์˜ ๋„์›€์œผ๋กœ ํ•ด๋‹น ๊ตฌ์กฐ๊ฐ€ ๋ฐ์ดํ„ฐ ํŒจ์นญ ๋กœ์ง ์ƒ ์ž์—ฐ์Šค๋Ÿฝ์ง€ ์•Š๋‹ค๋Š” ํŒ๋‹จ์ด ๋“ค์–ด ์„œ๋ฒ„์— ์ˆ˜์ • ์š”์ฒญํ•˜์—ฌ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค!

  • ~ Empty View ์ถ”๊ฐ€
<StEmptyView>
  <div>
    <IcEmptyLibrary />
    <p>์•„์ง ๋งˆ๊ฐ๋œ ํˆฌํ‘œ๊ฐ€ ์—†์–ด์š”!</p>
  </div>
</StEmptyView>
  • ~ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์•„์ดํ…œ๊ฐ„ ๊ฐ„๊ฒฉ ๋ฒ„๊ทธ ํ•ด๊ฒฐ
:first-child {
    margin-left: 2rem;
  }
  :last-child {
    margin-left: 0; // โœ… div๋กœ ๊ฐ์‹ธ๊ณ  ์žˆ๋Š” ๊ตฌ์กฐ๋ผ ์ด๊ฑธ ๋„ฃ์–ด์ฃผ์ง€ ์•Š์œผ๋ฉด ์™ผ์ชฝ์— ๋งˆ์ง„์ด ์ƒ๊ฒจ์„œ ๋„ฃ์–ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค!
    margin-right: 2rem;
  }

โ†’ ๋ถ€๋ชจ์ปดํฌ๋„ŒํŠธ์ธ MonthVoting.tsx์—์„œ ์ž์‹ ์„ ํƒ์ž๋กœ ๊ฐ„๊ฒฉ์„ ์กฐ์ •ํ•˜๋ ค๊ณ  ๊ณ„์† ์‹œ๋„ํ–ˆ๋Š”๋ฐ, ๊ทธ๋ƒฅ ์ž์‹ ์ปดํฌ๋„ŒํŠธ์ธ EndedVoting.tsx์—์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ์ฒ˜๋ฆฌํ•ด์ฃผ๋‹ˆ ๊ฐ„๊ฒฉ์ด ๊น”๋”ํ•˜๊ฒŒ ๋งž๋”๋ผ๊ตฌ์š”!

โœ… PR Point

1๏ธโƒฃ SWR์„ ์ ์šฉํ•˜๋ฉด์„œ ๊ฐ€๋กœ ๋ฌดํ•œ์Šคํฌ๋กค ์•„์ดํ…œ๋“ค์„ state๋กœ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๊ฒŒ ๋˜์—ˆ์–ด์š”!
๊ทธ๋ž˜์„œ ํˆฌํ‘œ ์‚ญ์ œ ํ›„ ์ƒˆ๋กœ๊ณ ์นจ์„ ๋ฐœ์ƒ์‹œ์ผœ์„œ ์‚ญ์ œ ํ›„ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ค์‹œ ์ญ‰ ๋ Œ๋”๋ง๋˜๋„๋ก ์ฒ˜๋ฆฌํ–ˆ๋Š”๋ฐ ์ด๊ฒŒ ์ตœ์„ ์ธ์ง€ ์•„์ง ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ํ•œ ๋ฒˆ ๋ด์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!

const handleConfirmModal = (id: string) => {
    handleDeleteVote(id);
    setIsShowing((prev) => !prev);
    window.location.reload();
  };

2๏ธโƒฃ ์ฝ”๋“œ๋ฅผ ์ตœ๋Œ€ํ•œ ์ •๋ฆฌํ•œ๋‹ค๊ณ  ํ–ˆ๋Š”๋ฐ ์•„์ง ์ตœ๋Œ€ํ•œ cleanํ•œ์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ํ•œ ๋ฒˆ ๋ด์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ๐Ÿ™๐Ÿป

3๏ธโƒฃ SWR ํ˜ธ์ถœ ์ด์Šˆ
image
โ†’ ์ƒ๋‹จ ์‚ฌ์ง„์ด ์„ธ๋กœ ์Šคํฌ๋กค์„ ์ฒ˜์Œ ํ˜ธ์ถœํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ์ฝ˜์†”์— ์ฐ์—ˆ์„ ๋•Œ์ธ๋ฐ์š”, ๋ณด์‹œ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ํ˜ธ์ถœ์ด ๋ณต์ˆ˜๋กœ ์ด๋ฃจ์–ด์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
SWR ๊ณต์‹ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์— ์ด์Šˆ๋กœ ์˜ฌ๋ผ์˜จ ๊ธ€ [SWRInfinte bug]: repeated api calls for initial page index ์„ ๋ณด๋‹ˆ useSWRInfinite ์ž์ฒด์˜ ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™๊ธฐ๋„ ํ•œ๋ฐ, ์•„์ง ์™„์ „ํžˆ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์€ ์ฐพ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค!๐Ÿ˜ญ

๐Ÿ‘€ ์Šคํฌ๋ฆฐ์ƒท

2023-02-09.10.11.13.mov

Happhee and others added 23 commits February 6, 2023 16:08
@netlify
Copy link

netlify bot commented Feb 9, 2023

โœ… Deploy Preview for deluxe-otter-55aa15 ready!

Name Link
๐Ÿ”จ Latest commit 7a88827
๐Ÿ” Latest deploy log https://app.netlify.com/sites/deluxe-otter-55aa15/deploys/63e4fc0471bb1e0008ae1928
๐Ÿ˜Ž Deploy Preview https://deploy-preview-155--deluxe-otter-55aa15.netlify.app/
๐Ÿ“ฑ Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@pinktopaz pinktopaz changed the title Refactor/145 [ ๐Ÿ“š Library ] ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฆฌํŒฉํ† ๋ง Feb 9, 2023
@pinktopaz pinktopaz changed the base branch from master to develop February 9, 2023 14:16
Copy link
Contributor

@Happhee Happhee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋–ต๊ฒฝ์ด ์„œ๋ฒ„์™€์˜ ์†Œํ†ต๋„ ์ด๋ฒˆ์— ํ•œ๋ฒˆ๋” ์„ฑ์žฅํ•˜๊ฒŒ ๋œ ๊ณ„๊ธฐ๊ฐ€ ์•„๋‹๊ฐ€ ์‹ถ์–ด! ๊ธ€๊ตฌ ์ €๊ฑฐ ์ฝ˜์†” ๋งŽ์ด์ฐํžˆ๋Š”๊ฑฐ ๋‚˜๋„ ๊ณ„์† ์ฐพ์•„๋ณด๊ณ  ์ด๋”ฐ์œ !! ํ˜น์‹œ๋ชจ ์ฐพ๊ฒŒ ๋ฐ๋ฉด ๊ณต์œ  ๋ถ€ํƒํ•ด!!

์ €๊ฒŒ ๋ณด๋‹ˆ๊นŒ swr์—์„œ ํ‚ค๊ฐ€ ์œ ์ผํ•œ ํ‚ค๊ฐ€ ์•„๋‹ˆ๋ฉด? ๋ฐ˜๋ณตํ˜ธ์ถœํ•œ๋‹ค๋Š”๋ฐ useSWRInfinite์—์„œ ์ด ํ˜„์ƒ์ด ์ƒ๊ฐ๋ณด๋‹ค ๋‹ค๋“ค ๋งŽ์ด ๋‚˜ํƒ€๋‚˜๋”๋ผ๊ตฌ! ์ฐจ๊ทผ์ฐจ๊ทผ ์•Œ์•„๋ณด์ž! ๊ณ ์ƒํ•ด์จ !!

Comment on lines +8 to +11
const getKey = (prevLastDate: number, allVoteInfo: AxiosResponse<EndedVoteInfo>) => {
if (prevLastDate === 0) return `/vote/library/scroll/all?flag=${prevLastDate}`;
if (allVoteInfo) return `/vote/library/scroll/all?flag=${allVoteInfo.data.dates[allVoteInfo.data.dates.length - 1]}`;
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„˜ ์กฐ์ฟ ์š”!

@@ -7,15 +7,12 @@ import { picmeGetFetcher } from '../axios';
export const useGetMonthlyLibraryInfo = (date: number) => {
const { data, isLoading, error, size, setSize } = useSWRInfinite<AxiosResponse<VoteInfo[]>>(
(idx: number, monthlyVoteInfo: AxiosResponse<VoteInfo[]>) => {
// date ๋ฐ›์œผ๋ ค๊ณ  ๋”ฐ๋กœ getKey ์„ ์–ธํ•œ๊ฑธ ๋บ์–ด!!!!
if (idx === 0) return `/vote/library/scroll/month?flag=${0}&date=${date}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (idx === 0) return `/vote/library/scroll/month?flag=${0}&date=${date}`;
if (!idx ) return `/vote/library/scroll/month?flag=0&date=${date}`;

์ด์ผ€ ํ•˜๋ฉด ๋ฐ๋Š”๊ฑฐ ์•„๋‹Œ๊ฐ€?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์šฐ์›…! ๋งž๋‹ค! ๋” ๊น”๋”ํ•˜๋„ค! ๋ฐ”๊ฟจ์–ด์š”์˜ค

@@ -45,15 +44,15 @@ const Library = () => {
navigate('/home');
}}
/>
{allVoteInfoList.list.length !== 0 ? (
{allVoteInfoList.dateList.length !== 0 ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{allVoteInfoList.dateList.length !== 0 ? (
{ allVoteInfoList.dateList.length ? (

๋กœ ์“ฐ๋ฉด ๋ ๊ฒƒ๊ฐ™์•„์šฉ~!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฐ˜์˜ํ•ด๋– ! ๊ณ ๋งˆ์–ด!!!

Comment on lines 60 to 65
<StEmptyView>
<div>
<IcEmptyLibrary />
<p>์•„์ง ๋งˆ๊ฐ๋œ ํˆฌํ‘œ๊ฐ€ ์—†์–ด์š”!</p>
</div>
</StEmptyView>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธฐ์„œ ์‹œ๋งจํ‹ฑ ํƒœ๊ทธ์— ๋ฐ”๋กœ ์Šคํƒ€์ผ์„ ์ ์šฉํ•ด๋„ ๋ ๊ฑฐ๊ฐ™์€๋ฐ ํ•˜์œ„์— div ๋ฅผ ์ค˜์„œ ๊ตฌ์„ฑํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ?

Copy link
Contributor Author

@pinktopaz pinktopaz Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„์ด์ฝ˜์ด๋ž‘ ํ…์ŠคํŠธ๋ฅผ ํ•œ ๋ฉ์–ด๋ฆฌ๋กœ ์ทจ๊ธ‰ํ•˜๊ณ  ์‹ถ์—ˆ๋‚˜๋ด...!
๊ทผ๋ฐ ์‹œ๋ฃจ ๋ง๋Œ€๋กœ ํ•˜๋Š”๊ฒŒ ๋” ๊น”๋”ํ•  ๊ฒƒ ๊ฐ™์•„์„œ ๊ทธ๋ ‡๊ฒŒ ๋ฐ”๊ฟ”์„œ ์ ์šฉํ–ˆ์–ด! ๊ณ ๋งˆ์–ด!!

@@ -37,7 +37,7 @@ export const getCurrentVoteDatailData = async (voteid: string | undefined) => {

export const getCurrentVoteData = async (resCursorId: number) => {
try {
const data = await client.get<AxiosResponse<VoteResultData>>(`vote/getCurrentVote/${resCursorId}`);
const data = await client.get<AxiosResponse<VoteResultData>>(`vote/list/${resCursorId}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธฐ ์ธ์ž ์ด๋ฆ„ resCursorId ๊ฐ€ ๋””๋ฒจ๋กญ์—์„œ๋Š” cursorId ์—ฌ์„œ ๋‚˜๋„ ๋จธ์ง€์ปจํ”Œ๋ฆญํŠธ ํ•ด๊ฒฐํ•  ๋•Œ cursorId ๋กœ ํ•ด์„œ ๋จธ์ง€ํ–ˆ๋Š”๋ฐ ์–ด๋–ค ์ด๋ฆ„์ด ๋” ์ ํ•ฉํ• ๊นŒ? ํ†ต์ผํ•ด์•ผํ• ๋“ฏ!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๊ฑฐ ๋‚ด๊ฐ€ ๋ฆฌํŒฉํ† ๋งํ•œ ๋ถ€๋ถ„์ธ๋ฐ SWR๋กœ ์ ์šฉํ•˜๋ฉด์„œ ์ด ํ•จ์ˆ˜๋Š” ์—†์–ด์กŒ์–ด!! ใ…Žใ…Ž

Copy link
Member

@Brokyeom Brokyeom Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๊ฑฐ ๋‚ด๊ฐ€ ๋ฆฌํŒฉํ† ๋งํ•œ ๋ถ€๋ถ„์ธ๋ฐ SWR๋กœ ์ ์šฉํ•˜๋ฉด์„œ ์ด ํ•จ์ˆ˜๋Š” ์—†์–ด์กŒ์–ด!! ใ…Žใ…Ž

์•„ํ•˜ ๊ตฟ ใ…Ž

<StVotingTitle>{voteData.title}</StVotingTitle>
<StVotingDate>
{time1}์›” {time2}์ผ
{createdMonth}์›” {createdDate}์ผ
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ช…ํ™•ํ•œ ๋„ค์ด๋ฐ ๊ตฟ~

const handleModal = (prev: boolean) => {
setIsShowing((prev) => !prev);
};

const handleMoveResult = () => {
const handleGoToResult = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ธฐ๋Šฅ์— ๋Œ€ํ•ด์„œ ๋” ๋ช…ํ™•ํ•˜๊ฒŒ ์•Œ์•„๋ณด๊ฒŒ ํ•˜๋ ค๋Š” ์˜๋„๊ฐ€ ์ข‹๊ตฐ์š”~!

@Brokyeom
Copy link
Member

Brokyeom commented Feb 10, 2023

์•ผ๋ฌด์ง„ ๋ฆฌํŒฉํ† ๋ง ๊ตฟ! SWR์˜ ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ธฐ๋Šฅ ํ™œ์šฉ์— ๋Œ€ํ•ด์„œ ํ•œ๋ฒˆ ๋” ๋ฐฐ์šฐ๊ฒŒ ๋˜๋„ค
ํ•จ์ˆ˜ ๋„ค์ด๋ฐ ๋“ฑ ๋””ํ…Œ์ผํ•œ ๋ถ€๋ถ„๊นŒ์ง€ ์ข€๋” ์•Œ์•„๋ณด๊ธฐ ์‰ฌ์šด ์ฝ”๋“œ๋ฅผ ์งœ๋ ค๋Š” ๋…ธ๋ ฅ์ด ๋ณด์—ฌ์„œ ์ข‹๋‹ค!! ๊ณ ์ƒํ–ˆ์–ด~!~

Copy link
Contributor

@iamphj3 iamphj3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋–ต๊ฒฝ์ด ๊ฐ€๋กœ์„ธ๋กœ ๋ฌดํ•œ์Šคํฌ๋กค ๋ฆฌํŒฉํ† ๋ง๊นŒ์ง€ ํผ ๋ฏธ์ณค๋‹ค... useSWRInfinite๊นŒ์ง€ ์“ธ ์ˆ˜ ์žˆ๋Š” ์šฐ๋ฆฌ,,,, ์งฑ์ด์•ผ,,,,

Comment on lines 40 to 42
const handleDeleteVote = (id: string) => {
deleteVote(id);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setState์™€ ๊ฐ™์ด ๋ณ€๊ฒฝ๋œ ๋ฐ์ดํ„ฐ๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, mutate ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜๋ฉด ๋œ๋‹ค.
mutateํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ํ•ด๋‹น ์ƒํƒœ๋ฅผ ์ฆ‰์‹œ fetchํ•˜๊ณ  ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐฑ์‹ ํ•œ๋‹ค.

๋ผ๊ตฌ ํ•ฉ๋‹ˆ๋‘ฅ!! ๊ทธ๋ฆฌ๊ตฌ axios ์„œ๋ฒ„ํ†ต์‹  ๋ถ€๋ถ„์ธ ๊ฒƒ ๊ฐ™์€๋ฐ async, await ๋„ฃ์–ด์ค˜์•ผ ํ• ๊ฑฐ๊ฐ™์•„์šฉ!

Suggested change
const handleDeleteVote = (id: string) => {
deleteVote(id);
};
const handleDeleteVote = async (id: string) => {
await deleteVote(id);
return mutate();
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ผฌ๋งˆ์–ด!! mutate SWR ๋•Œ๋ฌธ์— ์‹ค์ปท ๊ณต๋ถ€ํ•ด๋†“๊ณ  ์ ์šฉ์„ ๋ชปํ–ˆ๋„ค!ใ… ใ…  ๋•๋ถ„์— ์ด์ œ ์ž˜ ์“ธ ์ˆ˜ ์žˆ๊ฒ ๋‹ค ๋ฐ˜์˜ํ•ด๋– !!!

import { picmeGetFetcher } from '../axios';

export const useGetMonthlyLibraryInfo = (date: number) => {
const { data, isLoading, error, size, setSize } = useSWRInfinite<AxiosResponse<VoteInfo[]>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1๏ธโƒฃ SWR์„ ์ ์šฉํ•˜๋ฉด์„œ ๊ฐ€๋กœ ๋ฌดํ•œ์Šคํฌ๋กค ์•„์ดํ…œ๋“ค์„ state๋กœ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๊ฒŒ ๋˜์—ˆ์–ด์š”!
๊ทธ๋ž˜์„œ ํˆฌํ‘œ ์‚ญ์ œ ํ›„ ์ƒˆ๋กœ๊ณ ์นจ์„ ๋ฐœ์ƒ์‹œ์ผœ์„œ ์‚ญ์ œ ํ›„ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ค์‹œ ์ญ‰ ๋ Œ๋”๋ง๋˜๋„๋ก ์ฒ˜๋ฆฌํ–ˆ๋Š”๋ฐ ์ด๊ฒŒ ์ตœ์„ ์ธ์ง€ ์•„์ง ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ํ•œ ๋ฒˆ ๋ด์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!

-> ์ฐพ์•„๋ณด๋‹ˆ๊นŒ SWR๋กœ ์ƒํƒœ๊ด€๋ฆฌ๋ฅผ ํ•˜๋ ค๋ฉด mutate๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค๊ตฌ ํ•˜๋„ค!
์„ฑ๊ฒฝ์ด ๋ธŒ๋žœ์น˜ ๋‚ด ๋กœ์ปฌ์—์„œ ๋ฐ›์•„์„œ ์ž‘์—…ํ•ด๋ดค๋Š”๋ฐ ์ƒˆ๋กœ๊ณ ์นจ ํ•˜์ง€ ์•Š๊ณ ๋„ ์‚ญ์ œํ•œ ๊ฑฐ ํ™”๋ฉด์— ๋ฐ”๋กœ ๋ฐ˜์˜๋˜๋Š”๊ฑฐ ํ™•์ธ๋ผ์„œ suggestion์œผ๋กœ ์ˆ˜์ •ํ•œ ๋ถ€๋ถ„ ๋‹ฌ์•„๋†“์„๊ฒŒ!!

์š”๊ฑฐ ์ฐธ๊ณ ํ–ˆ์–ด! 3. SWR๋กœ ์ƒํƒœ๊ด€๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ• ๊นŒ?

Suggested change
const { data, isLoading, error, size, setSize } = useSWRInfinite<AxiosResponse<VoteInfo[]>>(
const { data, isLoading, error, size, setSize, mutate } = useSWRInfinite<AxiosResponse<VoteInfo[]>>(

Comment on lines 32 to 33
setSize,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setSize,
};
setSize,
mutate,
};

Comment on lines +21 to +23
const createdAtStr = voteData.createdAt.toString();
const createdMonth = createdAtStr.slice(5, 6) === '0' ? createdAtStr.slice(6, 7) : createdAtStr.slice(5, 7);
const createdDate = createdAtStr.slice(8, 9) === '0' ? createdAtStr.slice(9, 10) : createdAtStr.slice(8, 10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜น ํ›จ์”ฌ ๋ช…ํ™•ํ•ด์กŒ๋‹น ๊ตฟ~!!

handleDeleteVote(id);
setIsShowing((prev) => !prev);
window.location.reload();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
window.location.reload();

Comment on lines 72 to 78
:first-child {
margin-left: 2rem;
}
:last-child {
margin-left: 0;
margin-right: 2rem;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๋ ‡๊ฒŒ ํ•ด๋ฒ„๋ฆฌ๋ฉด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ํ•ญ๋ชฉ์ด 1๊ฐœ๋ฐ–์— ์—†์„ ๋•Œ :last-child๊ฐ€ ์ ์šฉ์ด ๋˜์–ด์„œ, margin-left๊ฐ€ 0์ด ๋œ๋‹ค ใ…œใ…œ!
๋‚˜๋„ ๊ถ๊ธˆํ•ด์„œ ์ˆ˜์ •ํ•ด๋ดค๋Š”๋ฐ ํ•ด๊ฒฐํ•œ๊ฑฐ๊ฐ™์•„์„œ suggestion์œผ๋กœ ๋‹ฌ์•„๋ณผ๊ฒŒ!! ๋ฐ‘์— MonthVoting.tsx์—๋„ ํ•˜๋‚˜ ๋” ์žˆ์—‰!!!
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2023-02-10 แ„‹แ…ฉแ„’แ…ฎ 10 39 29

Suggested change
:first-child {
margin-left: 2rem;
}
:last-child {
margin-left: 0;
margin-right: 2rem;
}
margin-right: 1.521rem;
:last-child {
margin-right: 2rem;
}

Copy link
Contributor Author

@pinktopaz pinktopaz Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฐ์ดํ„ฐ ํ•˜๋‚˜์ผ ๋•Œ๋ฅผ ํ…Œ์ŠคํŠธ๋ฅผ ๋ชปํ•ด๋ดค์—ˆ๊ตฌ๋‚˜ ๋‚ด๊ฐ€!! ์ญˆ์•„

 margin-right: 1.521rem;

์ด๊ฑฐ๋Š” gap์—์„œ ์ด ์—ญํ• ์„ ํ•˜๊ณ  ์žˆ์–ด์„œ ๋บ์–ด! ์ด๊ฒƒ๊นŒ์ง€ ๋„ฃ์œผ๋ฉด ์‚ฌ์ด ๊ฐ„๊ฒฉ์ด ๋” ๊ธธ์–ด์ ธ์„œใ… ใ… 
๊ณ ๋งˆ์–ด ํ˜„์ง€ ๋˜‘๋˜‘์ด~

Comment on lines 86 to 88

width: 100%;
margin-top: 1.7rem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๋ ‡๊ฒŒ ํ•˜๋ฉด ๋งˆ์ง„ ์ด์Šˆ ํ•ด๊ฒฐ๋˜๋Š”๊ฑฐ๊ฐ™์•„!!!

Suggested change
width: 100%;
margin-top: 1.7rem;
display: flex;
width: 100%;
padding-left: 2rem;
margin-top: 1.7rem;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flex,margin์€ ์œ„์— ์žˆ์–ด์„œ padding๋งŒ ์ ์šฉํ•ด์จ! ๊ณ ๋งˆ์–ด!

@netlify
Copy link

netlify bot commented Feb 10, 2023

โœ… Deploy Preview for snazzy-seahorse-7d3184 ready!

Name Link
๐Ÿ”จ Latest commit 8fb84ff
๐Ÿ” Latest deploy log https://app.netlify.com/sites/snazzy-seahorse-7d3184/deploys/63e916cd2fca410007e834e5
๐Ÿ˜Ž Deploy Preview https://deploy-preview-155--snazzy-seahorse-7d3184.netlify.app/
๐Ÿ“ฑ Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Member

@woogisea woogisea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๊ณ ํ–ˆ์œผ์š”~~

Comment on lines 48 to 42
<StVotingPic src={voteData.url} onClick={handleMoveResult} />
<StVotingPic src={voteData.url} onClick={handleGoToResult} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๊ธฐ alt ํƒœ๊ทธ ํ•„์š”์—†๋‚˜์š”??? imgํƒœ๊ทธ์— onClick์ด๋ฒคํŠธ๋ฅผ ์ ์šฉํ•œ๊ฑฐ๋ผ๋ฉด cursor : pointer css๋ฅผ ํ†ตํ•ด ๋งˆ์šฐ์Šค ์ปค์„œ ๋ชจ์–‘์„ ๋ณ€๊ฒฝํ•ด์„œ ํด๋ฆญ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ •๋ณด๋ฅผ ์ค˜๋„ ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค~

},
);

const parseResultList = data?.map((item) => item.data).flat();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flat ์š”์†Œ๋Š” ์ฒ˜์Œ ๋ดค๋Š”๋ฐ ์œ ์šฉํ•˜๊ตฐ,,

@pinktopaz pinktopaz merged commit ce49191 into develop Feb 12, 2023
@Happhee Happhee deleted the refactor/145 branch March 22, 2023 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[๐Ÿ“šLibrary] ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฆฌํŒฉํ† ๋ง
5 participants