-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor: uuid 형식 문자열로 url 관리 , nextQuiz, previousQuiz, app.tsx 초기렌더… #15
Conversation
…, 기존 First_QUIZ_ID제거
src/App.tsx
Outdated
const { fetchQuizzesData, quizzesList } = useQuizStore(); | ||
useEffect(() => { | ||
fetchQuizzesData(); | ||
console.log(quizzesList, 'quizList'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(quizzesList, 'quizList'); |
pr을 생성하기 전과 후에 변경사항을 살펴보는 건 기본입니다.
src/store/useQuiz.ts
Outdated
_id: string; | ||
id: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
얘는 왜 아이디가 두 갠가요..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
블로그 글을 보면 보통 아래쪽에 이전글 다음글 버튼이 있죠? 지금 재원님이 하신 방식은 블로그로 치면 글이 백 개면 백개, 천 개면 천 개를 처음에 모두 받아오고 프론트에서 계속 관리하는 셈이에요. 과연 이렇게 할까요? 생각해보시고 변경하는 데 너무 오래 걸릴 것 같으면 일단 이렇게 계속 진행하세요~
pr에 디버깅용 콘솔로그는 남지 않게 해주세요. 조금만 성의를 들이면 됩니다.
…드를 이용 데이터가져오기, currentQuiz값기준으로 prev,next값 한번에가져오기,
src/components/Header.tsx
Outdated
|
||
useEffect(() => { | ||
if (location.pathname === '/' || !quizId) return; | ||
fetchQuizData(quizId); | ||
const isCurrentLoaded = currentQuiz.id === quizId; | ||
const isPrevNextLoaded = prevQuiz.id === quizId || nextQuiz?.id === quizId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이전 퀴즌의 아이디가 현재 퀴즈 아이디와 같거나 다음 퀴즈의 아이디가 현재 퀴즈 아이디와 같다면 이전 다음 퀴즈가 로드되어 있다
이게 무슨 뜻인가요..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변수명 신경써서 진행하겠습니다!
src/components/Header.tsx
Outdated
|
||
useEffect(() => { | ||
if (location.pathname === '/' || !quizId) return; | ||
fetchQuizData(quizId); | ||
const isCurrentLoaded = currentQuiz.id === quizId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 퀴즈의 아이디와 의도한 퀴즈 아이디(파람에서 추출한 아이디)가 다르다면 그건 에러를 던져야 할 상황인 것 같아요.
src/components/Header.tsx
Outdated
if (prevQuiz) { | ||
const currentValue = currentQuiz; | ||
setQuizState({ | ||
currentQuiz: prevQuiz, | ||
nextQuiz: currentValue, | ||
prevQuiz: undefined, | ||
}); | ||
} | ||
navigate(`/quizzes/${prevQuiz.id}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
navigate을 하면 퀴즈 아이디를 보고 스토어가 알아서 현재 퀴즈를 반환해주면 좋겠네요.
src/store/useQuiz.ts
Outdated
prevQuiz: {} as QuizType, | ||
nextQuiz: {} as QuizType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentQuiz에 더해 거짓말하는 코드가 점점 늘어나네요.
기존 퀴즈, 다음 퀴즈 들고 있는 로직은 없애는 게 나을 것 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 이전값과 다음값 가지고있는 로직은 없애도록 하겠습니다.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음보다 꽤 깔끔해졌네요 👍
감사합니다! |
refactor: 기존 number형태의 url 을 uuid형식의 문자열로 관리, nextQuizBtn, previousQuizBtn, handleStartQuiz 수정,