-
Notifications
You must be signed in to change notification settings - Fork 8
[7주차/치치] 워크북 제출합니다. #83
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
Conversation
| export const postImage = async (file: string | Blob) => { | ||
| const formData = new FormData(); | ||
| formData.append('file', file); | ||
|
|
||
| const response = await axiosInstance.post('/uploads', formData, { | ||
| headers: { | ||
| 'Content-Type': 'multipart/form-data' | ||
| } | ||
| }); |
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.
저는 이번 미션에서 서버에 파일을 보내는 방법을 잘 모르겠어서 어렵게 느껴졌어요. 이렇게 FormData로 파일을 담아 post 하는 방법이 있다는걸 처음 알았네요.. 저도 다시 구현해 봐야겠어요.
| alert("댓글 수정에 실패하였습니다 !! 다시 시도해 주세요."); | ||
| } | ||
| }); | ||
|
|
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.
useMutation이 컴포넌트 내부에 포함되어 있어서 UI 코드와 상태 관리 로직이 한 파일에 섞이면서 컴포넌트 길이가 조금 길어지고 있습니다. mutation 로직을 별도의 hooks 파일로 분리해두면 가독성과 유지보수 측면에서 더 유리해서한번 분리해보시는 것을 추천드립니다!
또한 지금은 쿼리 키가 많지 않아서 괜찮지만 쿼리 키가 많아지면 문자열로 직접 넣기보다 queryKeys.ts에서 중앙 관리하면 전체 쿼리 구조를 일관되게 유지할 수 있고, invalidate / getQueryData 시 실수나 누락을 줄일 수 있어서 시간 되실 때 구조 개선 방향으로 한번 고민해보셔도 좋을 것 같아요!
|
치치 이번 주차도 코드 직접 짜보려고 노력해주셔서 너무 멋집니다!! PR 오른쪽에 Development 7주차에 연결해주시고 머지해주세요~ |
✅ 워크북 체크리스트
✅ 컨벤션 체크리스트
📌 주안점