리액트 쿼리 기능에서 useQuery를 사용할 때 두 번째 인자에 함수를 넣어줘야 하는데 이때 즉시 실행하는 함수 형태로 넣어주지 않으면 에러가 발생한다.
stack overflow에서 같은 원인으로 발생한 문제를 올려둔 글이 있어 해당 답변을 통해 에러를 해결했다.
https://stackoverflow.com/questions/70319827/missing-queryfn-error-when-using-usequery
Missing queryFn error when using useQuery
As the title suggests, I am new to using useQuery and the associated libraries, I am trying to use it to fetch data and then populates a list of fields that I have created However when I run it I get
stackoverflow.com
useQuery('monster', fetchMonster(props.slug))
//위와 같은 코드를
useQuery('monster', () => fetchMonster(props.slug))
// 수정!
'에러 해결' 카테고리의 다른 글
[ React Error ] Failed to load config "react-app" to extend from. (0) | 2022.11.09 |
---|---|
[React]error: Warning: Each child in a list should have a unique "key" props (0) | 2022.04.25 |
[Git] error: failed to push some refs to (0) | 2022.01.04 |
[React] error: useRoutes() may be used only in the context of a <Router> component. (0) | 2021.11.27 |
[Aws]error: aws Amplify 배포할 때 이미지 유실 문제 (0) | 2021.11.25 |