[TanStack Query] Type 'string[]' has no properties in common with type 'InvalidateQueryFilters'.ts(2559)

2024. 11. 15. 11:10·Trouble Shooting
반응형

🚨 문제 상황

import {useMutation, useQueryClient} from '@tanstack/react-query';
import {deleteMedication} from '@/apis/medication/deleteMedication';

export const useDeleteMedication = () => {
  const queryClient = useQueryClient();

  return useMutation<void, Error, string>({
    mutationFn: deleteMedication,
    onSuccess: () => {
      queryClient.invalidateQueries(['medicationList']);
    },
    onError: (error: Error) => {
      console.error('Error deleting medication:', error);
    },
  });
};
  • queryClient.invalidateQueries(['medicationList']);
    • 이 부분에서 에러가 났다

 

🥁 해결 방법

import {useMutation, useQueryClient} from '@tanstack/react-query';
import {deleteMedication} from '@/apis/medication/deleteMedication';

export const useDeleteMedication = () => {
  const queryClient = useQueryClient();

  return useMutation<void, Error, string>({
    mutationFn: deleteMedication,
    onSuccess: () => {
      queryClient.invalidateQueries({queryKey: ['medicationList']});
    },
    onError: (error: Error) => {
      console.error('Error deleting medication:', error);
    },
  });
};
  • queryClient.invalidateQueries({queryKey: ['medicationList']});
    • 이렇게 고치니 해결되었다

 

깃허브 토론을 보면 버전 차이인 것 같다!

반응형

'Trouble Shooting' 카테고리의 다른 글

Next.js 15에서 router.replace() 사용 시 무한 리다이렉트 발생  (0) 2025.06.27
[React] svgr 세팅 - Duplicate identifier 'src'.  (0) 2024.11.14
[Next.js] React Hydration Error  (0) 2024.10.21
[html] svg 높이 설정 에러  (0) 2024.10.21
'Trouble Shooting' 카테고리의 다른 글
  • Next.js 15에서 router.replace() 사용 시 무한 리다이렉트 발생
  • [React] svgr 세팅 - Duplicate identifier 'src'.
  • [Next.js] React Hydration Error
  • [html] svg 높이 설정 에러
올콩
올콩
콩 심은 데 콩 난다
  • 올콩
    콩스토리
    올콩
  • 전체
    오늘
    어제
    • 분류 전체보기 (161) N
      • SSAFY (10)
      • Algorithm (85) N
        • 이론 (6)
        • 백준 (BOJ) (78) N
        • 프로그래머스 (1)
      • Trouble Shooting (8)
      • Frontend (6)
      • React (14) N
      • Next.js (3)
      • Vue (4)
      • Node.js (2)
      • HTML (9)
      • DevOps (3)
        • Git (3)
      • Language (9)
        • JavaScript (0)
        • Java (9)
      • Embedded (1)
      • CS (5)
        • Network (1)
        • Blockchain (4)
      • 자격증 (2)
  • 블로그 메뉴

    • GitHub
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    브루트포스
    싸피
    bfs
    html5
    DP
    우선순위큐
    블록체인
    Error
    Next.js
    vue
    SSAFY
    누적합
    리액트
    SSAFYcial
    재귀
    Java
    백준
    Heap
    파이썬
    알고리즘
    dfs
    강의
    힙
    오블완
    해시
    React
    Algorithm
    티스토리챌린지
    구현
    딕셔너리
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
올콩
[TanStack Query] Type 'string[]' has no properties in common with type 'InvalidateQueryFilters'.ts(2559)
상단으로

티스토리툴바