[김진우] Week19#554
Open
wecaners wants to merge 7 commits intocodeit-bootcamp-frontend:part3-김진우from
Hidden character warning
The head ref may contain hidden characters: "part3-\uae40\uc9c4\uc6b0-week19"
Open
Conversation
SINHOLEE
approved these changes
Jan 16, 2024
Comment on lines
+15
to
+27
| const getCurrentUser = async () => { | ||
| try { | ||
| const res = await instance.get(USERS_ENDPOINT, { | ||
| headers: { | ||
| Authorization: `Bearer ${getAccessToken()}`, | ||
| }, | ||
| }); | ||
| const { data } = res; | ||
| return data; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; |
Collaborator
There was a problem hiding this comment.
를 포함한 getLinks , getFolders 는 컴포넌트 밖으로 꺼내는게 좋아요. 컴포넌트가 리랜더링할 때 마다 해당 함수를 매번 새로 생성해야하니 이런식으로 코드를 작성하면 성능이 떨어지게됩니다. 코드 유지보수성 측면에서도 좋지 않구요
Comment on lines
+71
to
+99
| let links; | ||
| if (folderId === ALL_LINK_NAME) { | ||
| try { | ||
| const res = await instance.get(`/links`, { | ||
| headers: { | ||
| Authorization: `Bearer ${getAccessToken()}`, | ||
| }, | ||
| }); | ||
| const { data } = res; | ||
| links = data; | ||
| setFilteredLinks(links); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| } else if (typeof folderId === "number") { | ||
| try { | ||
| const res = await instance.get(`/folders/${folderId}/links`, { | ||
| headers: { | ||
| Authorization: `Bearer ${getAccessToken()}`, | ||
| }, | ||
| }); | ||
| const { data } = res; | ||
| links = data; | ||
| setFilteredLinks(links); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| } | ||
| return links; |
Collaborator
There was a problem hiding this comment.
const url = folderId === ALL_LINK_NAME ? link:forlders/${forderId}/link
하면 fetch 반복이 줄겠네요!
- setFiltered는 파생상태니 지양하자고 했었죠?
Comment on lines
+149
to
+161
| const addFolder = async () => { | ||
| instance.post( | ||
| `/folders`, | ||
| { | ||
| name: addFolderName, | ||
| }, | ||
| { | ||
| headers: { | ||
| Authorization: `Bearer ${getAccessToken()}`, | ||
| }, | ||
| } | ||
| ); | ||
| }; |
Collaborator
There was a problem hiding this comment.
addFolderName 변수를 암묵적인자로 받으려고 하니 컴퍼넌트안에 해당함수가 들어가있는거라고 판단했어요.
명시적인자로 밖에서 받을 수 있게하면, 해당 함수을 컴퍼넌트바깥으로 보낼 수 있어요.
Comment on lines
+28
to
+41
| const signup = async () => { | ||
| const res = await instance.post(`${SIGNUP_ENDPOINT}`, { | ||
| email: watch("email"), | ||
| password: watch("password"), | ||
| }); | ||
| const accessToken = res?.data.accessToken; | ||
| setAccessToken(accessToken); | ||
| res.status === 200 && router.push("/folder"); | ||
| }; | ||
|
|
||
| const signupMutation = useMutation({ | ||
| mutationFn: signup, | ||
| }); | ||
|
|
Collaborator
There was a problem hiding this comment.
- email, password를 명시적 인자오 받았으면 컴퍼넌트 밖으로 뺄 수 있음
- set...함수를 fetch 함수 내부에서 호출하는게 아니라, useMutation의 onSuccess 콜백 안에서 호출해야합나자
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
요구사항
기본
주요 변경사항
멘토에게