Replies: 1 comment
-
|
저는 3개 이상이 되면 확장 가능한 인터페이스라고 생각해요. 추가로 tanstack-query를 사용할 때 queryKey, queryFn 등을 설정하게 되는데요. export const useGetCardList = (
keyword, recruitmentStatus, category, division
) => {
return useQuery<ClubSearchResponse, unknown, ClubSearchResponse>({
queryKey: ['clubs', keyword, recruitmentStatus, category, division],
queryFn: () => getClubList(keyword, recruitmentStatus, category, division),
}),
});
};이렇게 객체 형태가 아니라 Prop을 순서대로 받아오면, queryKey 내에 정의할 props 순서와 불일치 가능성도 존재해요. 그래서 저는 객체로 유지하는 방식이 훨씬 안전성이 높을 것 같아요. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
https://github.com/Moadong/moadong/pull/823를 참고하면
파라미터 값 4개를 받는 getClubList() 함수를
객체로 만들어 전달해주도록 리팩토링했는데요!
이렇게 하나의 함수가 N개이상의 파라미터를 받을 시, 객체로 받는게 안전성이 높아지고 휴먼 에러가 적어질꺼라 생각이듭니다! 다들 어떻게 생각하나요? 의견과 파라미터 N개의 기준을 얘기해보죠~
Beta Was this translation helpful? Give feedback.
All reactions