Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Post 작성 서버 연결 #27
Post 작성 서버 연결 #27
Changes from all commits
58e1670
edc037d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
이 코드 패치에 대해 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험 및 개선 제안을 환영합니다:
isSuccess
변수가 사용되지 않는 것 같습니다. 이 변수를 사용하는 목적이 무엇인지 확인해 보세요. 필요하지 않다면 제거할 수 있습니다.UseGetPostListQueryInterface
인터페이스의 내용을 알 수 없기 때문에 해당 인터페이스의 정확성을 확인해야 합니다. 필요에 따라 인터페이스를 수정하거나 업데이트해야 할 수도 있습니다.그 외에는 코드의 논리적인 문제나 버그 위험이 보이지 않습니다.
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.
이 코드 패치에 대해 간략한 코드 리뷰를 도와드리겠습니다. 버그 위험과/또는 개선 제안을 환영합니다.
보시면 이 코드는 axiosPrivate라는 변수로 내보내기(export)됩니다. 이 변수는 Axios 인스턴스인 axios.create() 메서드로 생성되었습니다.
여러 옵션 중 하나로, "Content-Type" 헤더를 "application/json"으로 설정하는 headers 객체가 있습니다.
또한, withCredentials 옵션이 true로 설정되어 있습니다. 이는 요청과 관련된 쿠키 및 인증 정보가 포함된 응답을 사용하기 위해 필요한 설정입니다.
하지만 기존에 baseURL이 있었으나 제거되었네요. 이 부분이 삭제된 것이 의도된 동작인지 확실히 알 수는 없지만, 다른 곳에서 사용하여야 하는 API의 기본 URL을 설정해야 할 수 있습니다.
이외의 잠재적인 버그나 개선 사항은 현재 코드로는 파악하기 어렵습니다. 전체적인 프로그램의 구조나 다른 파일들의 연관성을 파악하지 못하므로, 이 코드 조각이 어떻게 사용되고 있는지 알 수 없습니다. 완전한 코드 리뷰를 위해서는 전체 코드 또는 더 많은 정보가 필요합니다.
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.
다음은 제시된 코드 패치에 대한 간단한 코드 리뷰입니다. 버그 위험 또는 개선 제안 사항이 있을 경우 언제든지 알려주세요:
useGetPostListInfiniteQuery
함수 내부의 수정된queryKey
는getPostListInfiniteQueryKey.byKeyword
함수를 사용하여 생성됩니다. 이 변경은 검색 키워드에 따라 쿼리 키를 동적으로 생성하도록 합니다.queryFn
은 페이지 매개변수와 함께getPostListQueryFn
함수를 호출하여 포스트 목록을 검색합니다. 해당 함수의 반환 형식은AugmentedGetPostListResponse
로 가져옵니다.getNextPageParam
과getPreviousPageParam
콜백 함수는 현재 페이지 및 페이지를 지속할 수 있는지 여부에 따라 다음 및 이전 페이지 매개변수를 반환합니다.수정된
getPostListQueryFn
은 페이징 결과를 반환하기 전에hasNextPage
를 계산하는 방식을 변경합니다. 수정된 수식은 더 정확한 결과를 제공합니다.getPostListInfiniteQueryKey
객체는 모든 포스트 및 특정 키워드(옵셔널)로 쿼리 키를 정의하는 데 사용됩니다.위의 상기 내용을 고려하면 주어진 코드 패치에서 버그가 없고 개선점도 조정되었습니다.
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.
위의 코드 패치는 좋아요 기능에 대한 코드로 보입니다. 몇 가지 개선 사항과 버그 리스크를 고려해 보겠습니다.
Axios Import: 라이브러리 import 구문이
import axios from "@/libs/axios";
로 되어 있습니다. 실제로 제공된 위치가 맞는지 확인하십시오. 명시적인 경로를 사용하는 대신,import axios from 'axios';
를 사용하는 것이 더 안전합니다.useLikePostMutationFn
함수: 현재 이 함수는 접근 토큰을 로컬 스토리지에서 가져오고 사용하며, 예상되는 데이터를 반환합니다. 다음과 같은 개선 사항을 고려할 수 있습니다:useLikePostMutation
함수:useMutation
후크를 사용하여 좋아요 작업을 초기화하고, 성공 시 쿼리를 재갱신합니다. 이 부분은 잘 구성되어 있는 것으로 보입니다.리터럴 문자열:
'/posts/like/${id}'
입니다. 리터럴 문자열을 사용하는 것보다 변수를 활용하여 동적 경로를 만드는 것이 더 좋습니다. 예를 들어,'/posts/like/' + id
또는 템플릿 리터럴(/posts/like/${id}
)을 사용하십시오.코드 일관성: 한 파일에 함수와 객체가 혼합되어 있습니다. 유지 관리 및 가독성을 위해 해당 함수들은 별도의 모듈로 분리하는 것이 좋습니다.
주석: 주석은 도움이 되지만, 올바른 맥락과 자세한 설명이 있는지 확인하십시오. 필요한 경우 주석을 추가하여 코드를 명확하게 설명할 수 있도록 합니다.
요약하면, 코드 패치는 대체로 잘 구성되어 있으며 작동할 것으로 보입니다. 개선 사항은 다음과 같습니다: Axios import 수정,
useLikePostMutationFn
함수의 안전성 강화, 리터럴 문자열 대체, 코드 일관성 유지 및 주석의 가독성 향상입니다.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.
코드 리뷰를 해드리겠습니다.
import
문을 이용하여client
모듈과axios
라이브러리 그리고PostInterface
와 관련된 타입들을 가져왔습니다.useMutation
과useQueryClient
훅스를 사용했습니다.getPostListInfiniteQueryKey
함수를 이용하여 쿼리 키를 생성하고,invalidateQueries
를 호출하여 해당 쿼리를 무효화합니다.useLikePostMutation
함수는useMutation
훅을 반환합니다. 성공적으로 실행되면onSuccess
핸들러에서queryClient.invalidateQueries
를 호출하여 해당 쿼리를 무효화합니다.useLikePostMutationFn
은 게시글 번호 (id
)를 기반으로 좋아요를 취소하는 비동기 함수입니다.accessToken
을 로컬 스토리지에서 가져와 인증 헤더에 포함시킵니다. 주석에서FIXME
로 표기된 리터럴은 수정이 필요한 부분을 나타냅니다.useLikePostMutation
함수를export
하여 다른 곳에서 사용할 수 있도록 합니다.default
키워드를 사용하여 모듈 전체를useLikePostMutation
으로 내보냅니다.개선사항:
useLikePostMutationFn
함수를export
하여 다른 곳에서도 사용할 수 있도록 하였는데, 이 부분이 명확한지 확인해야 합니다.FIXME
에서 리터럴 값을 제거하고 의미 있는 상수 또는 변수를 사용하는 것이 가독성면에서 좋습니다.버그 및 위험 사항:
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.
주어진 코드 패치를 검토해보겠습니다.
주요 변경 사항:
postAttachUrls
의 타입이string[]
에서postAttachUrlsType[]
로 변경되었습니다.QuoteInfoType
이 추가되었습니다.postAttachUrlsType
이 추가되었으며,attachNo
,attachUrl
,attachType
속성을 포함하고 있습니다.개선 제안: