<aside> 💡 2022.12.08. 김관경
</aside>
// useQuery의 Type들
export function useQuery<
TQueryFnData = unknown,
TError = unknown,
TData = TQueryFnData,
TQueryKey extends QueryKey = QueryKey
>
// useMutation의 Type들
export function useMutaion<
TData = unknown,
TError = unknown,
TVariables = void,
TContext = unknown
>
const { mutate, isError, error } = useMutation<
Promise<MyKeywordData>,
AxiosError,
AddKeywordData
>({
mutationFn: mutateAddKeyword,
onSuccess: (addKeywordResponse: MyKeywordData) => {
queryClient.setQueryData(
[REACT_QUERY_KEY.MY_KEYWORD_LIST, communityId],
(old: MyKeywordData[] | undefined) => {
if (!old) {
return [addKeywordResponse];
}
return [...old, addKeywordResponse];
},
);
const prevAddedKeyword: MyKeywordData = {
keywordId: addKeywordResponse.keywordId,
keywordName: addKeywordResponse.keywordName,
};
handlePrevKeyword(prevAddedKeyword);
},
});
Argument of type '{ mutationFn: (addKeywordData: AddKeywordData) => Promise<MyKeywordData>; onSuccess: (addKeywordResponse: any) => void; }' is not assignable to parameter of type 'MutationKey'. Object literal may only specify known properties, and 'mutationFn' does not exist in type 'readonly unknown[]'.ts(2769)
라는 에러를 발생시키고 있었다.