24.12.13 - TanstackQuery, queryKey

강연주·2024년 12월 14일

📚 TIL

목록 보기
112/186

If your query function depends on a variable, include it in your query key.
Since query keys uniquely describe the data they are fetching, they should include any variables you use in your query function that change.


🖥️ function Todos({ todoId }) {
  const result = useQuery(['todos', todoId], () => fetchTodoById(todoId))
}

fetchTodoById 함수는 todoId 인자를 사용(의존적)하고 이럴 때 사용되는 변수는 queryKeys에도 포함되어야 한다. ➡️ queryKey: ['todos', todoId]


그럼 invalidateQueries에서 쓰이는 "meetups"는 지금 제 역할을 못 하고 있다는 말인가?


🌟 HTMLElement 와 HTMLInputElement

🌟 input, select, button

profile
아무튼, 개발자

0개의 댓글