-
Notifications
You must be signed in to change notification settings - Fork 23
[함헌규] sprint12 #145
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
base: next-함헌규
Are you sure you want to change the base?
[함헌규] sprint12 #145
The head ref may contain hidden characters: "next-\uD568\uD5CC\uADDC-sprint12"
Conversation
| onSuccess: () => { | ||
| if (initialValue) { | ||
| const changedFields: Partial<CreateProductRequest> = {}; | ||
| if (data.name !== initialValue.name) changedFields.name = data.name; | ||
| if (data.description !== initialValue.description) | ||
| changedFields.description = data.description; | ||
| if (data.price !== initialValue.price) | ||
| changedFields.price = data.price; | ||
| if (Object.keys(changedFields).length > 0) | ||
| return (mutation as EditMutation).mutate(changedFields); | ||
| } | ||
| return (mutation as CreateMutation).mutate({ | ||
| ...data, | ||
| images: [`https://${imageUrl}`], | ||
| }); | ||
| }, | ||
| }); |
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 (data.name !== initialValue.name) changedFields.name = data.name; | ||
| if (data.description !== initialValue.description) | ||
| changedFields.description = data.description; | ||
| if (data.price !== initialValue.price) | ||
| changedFields.price = data.price; |
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.
비슷한 모양의 코드가 반복되는데 반복문이나 함수형 프로그래밍적으로 접근해보면 어떨까요?
| async (error) => { | ||
| const originalRequest = error.config; | ||
|
|
||
| if (originalRequest.url === 'auth/refresh-token') { |
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.
직관적으로 파악하기 힘든 조건의 경우는 변수 또는 함수로 추상화해주면 파악하기 쉬워질 것 같아요.
e.g.
const hasRefreshTokenRequestFailed = originalRequest.url === 'auth/refresh-token'
if (hasRefreshTokenRequestFailed) {}
요구사항
기본
프론트엔드 배포
주요 변경사항