-
Notifications
You must be signed in to change notification settings - Fork 1
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
React Query 설치 및 팀소서 이슈 부분에 적용 #199
Conversation
* 원격 요청 API로 추상화
- TeamInfoData의 타입 뎁스 줄이기 - 잘못된 팀 아이디에 접근했을 경우 에러처리
* 이슈 작성 이후 받는 Response값을 더 자세하게 받음
울 웹쁜이 고생많았어 ! 여기서 미리보기로 보면서 쉬어~ 다른 웹쁜이들한테도 자랑해줘~ |
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.
드디어 리액트 쿼리 적용🥳 수고했어 서진아 !!
export type TeamInfoData = { | ||
teamDetailData: { | ||
teamDetail: TeamDetail; | ||
teamMemberCount: number; | ||
teamMemberList: TeamMemberNoneId[]; | ||
}; | ||
teamDetail: TeamDetail; | ||
teamMemberCount: number; | ||
teamMemberList: TeamMemberNoneId[]; | ||
}; |
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.
이런 것도 리팩토링 해주고 진짜 꼼꼼하다 !! depth 줄일 수 있었는데 내가 왜 이렇게 했지 ㅋㅋㅋㅋ 고마워 👍👍
src/infrastructure/remote/team.ts
Outdated
.catch((error) => { | ||
console.error(error.response); | ||
}); | ||
console.log(response); |
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(response);
는 지워주세요 ~~!
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.
고마우이~!!
function TeamNewIssue() { | ||
const navigate = useNavigate(); | ||
const { teamID } = useParams(); |
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.
여기에도 똑같이 if (teamID === undefined) navigate('/');
필요한가?
src/presentation/pages/Team/Main/index.tsx에서는 추가했길래 !!
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.
완전 꼼꼼하게 봐줬구나.. 감사합니둥!!
추가해둘게~!
useEffect(() => { | ||
if (teamID === undefined) return; | ||
if (!isChecked) { | ||
(async () => { | ||
const { issueList } = await api.teamService.getTeamIssue(teamID); | ||
setIssueList(issueList); | ||
})(); | ||
} else { | ||
(async () => { | ||
const { issueList } = await api.teamService.getMyIssue(teamID); | ||
setIssueList(issueList); | ||
})(); | ||
} | ||
}, [isChecked]); | ||
const { data: teamIssueList } = useQuery( | ||
['teamIssueList', teamID], | ||
() => api.teamService.getTeamIssue(teamID ?? ''), | ||
{ enabled: !isChecked }, | ||
); | ||
const { data: myIssueList } = useQuery( | ||
['myIssueList', teamID], | ||
() => api.teamService.getMyIssue(teamID ?? ''), | ||
{ enabled: isChecked }, | ||
); |
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.
그치... 먼가 박박 간단해졌어..
그리고 cleanup 함수(useEffect의 return문 안에 쓰는거!) 안 해줘도 그 에러가 안 뜨더라구.... 박박..... 우리 열심히 했는데...
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.
ㅋㅋㅋㅋ 그래도 좋은 경험이었다구 생각! 박박 수고했다😻
울 웹쁜이 고생많았어 ! 여기서 미리보기로 보면서 쉬어~ 다른 웹쁜이들한테도 자랑해줘~ |
7efc02a
to
dff0308
Compare
울 웹쁜이 고생많았어 ! 여기서 미리보기로 보면서 쉬어~ 다른 웹쁜이들한테도 자랑해줘~ |
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.
리팩토링까지 세세하게 잘 해주셨네염 !!!! 리액트 쿼리 적용하는 부분 잘 참고하겠읍니다 ㅎ,ㅎ
⛓ Related Issues
📋 작업 내용
📌 PR Point
충격적인 사실..
useMutation을 안 해도 데이터가 알아서 패칭된다는 사실..
그래도 써보려고 했는데 코드가 더 복잡해져서 관뒀습니다 ㅜ
혹시 쓰고 성공한 사례가 있다면 알려주세요..
React Query를 쓰는 방법
사용X
사용O
그 외 리팩토링한 부분
왜 했느냐? => 점을 줄이기 위하여
🔬 Reference