UseMutation Error

miin·2024년 1월 19일
0

Trouble Shooting

목록 보기
1/3
post-thumbnail

UseMutationOptions<unknown, Error, void, unknown>' 유형과 공통적인 속성이 없습니다

'() => Promise<AxiosResponse<any, any>>' 유형에 'UseMutationOptions<unknown, Error, void, unknown>' 유형과 공통적인 속성이 없습니다.ts(2559)

  const fetch = async () => {
    const axiosInstance = await AxiosToken();
    return axiosInstance.post(`/api/tayo/10/enroll/${similarList?.id}`);
  };

  const joinToGati = () => {
    const deleteAccountHandler = useMutation(() => fetch);
  };

해결코드

useMutation에서 지정한 유형이 전달하는 함수와 일치하는지 명확하게 적어줘야한다

  const fetch = () => {
    const axiosInstance = await AxiosToken();
    return axiosInstance.post(`/api/tayo/10/enroll/${similarList?.id}`);
  };

  const joinToGati = async () => {
    return useMutation({
      mutationFn: fetch,
    });
  };

https://beomy.github.io/tech/react/tanstack-query-v4/

0개의 댓글