리액트 쿼리의 fetchQuery시 새로 만들어진 키가 stale되지 않는 이슈 #44
doggopawer
started this conversation in
Issue
Replies: 2 comments
-
해결방법 import React from 'react'
import { useFormContext } from 'react-hook-form'
import Image from 'next/image'
import Input from '@/components/ui/Input'
import Assets from '@/config/assets'
import { useItemsQuery } from '@/hooks/api/useItemsQuery'
const SearchInput = () => {
const { register, getValues } = useFormContext()
const { fetchNextPage } = useItemsQuery({
category: getValues('category'),
priceRange: getValues('priceRange'),
cardTitle: getValues('cardTitle'),
status: ['TRADE_AVAILABLE'],
size: 5,
})
return (
<div className="relative w-4/5">
<Input
{...register('cardTitle')}
placeholder="찾으시는 물건을 입력해주세요."
/>
<div
className="absolute right-3 top-2.5 hover:cursor-pointer"
onClick={() => {
fetchNextPage()
}}
>
<Image src={Assets.search} alt="검색 아이콘" />
</div>
</div>
)
}
SearchInput.displayName = 'SearchInput'
export default SearchInput 해당 이슈는 useInfiniteQuery가 아닌 queryClient.fetchInfiniteQuery를 사용했기 때문에 일어난 이슈였습니다. 리액트 쿼리 사용시 참고 바랍니다. |
Beta Was this translation helpful? Give feedback.
0 replies
-
아아 전역이 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
문제상황

리액트에서 카테고리 인풋에 원하는 값을 넣고 검색 버튼을 누르면
리액트 쿼리 키에 "입력한 값" 이 포함된 키가 생성되고 새로운 데이터가 생성되는게 기대가 되지 만,
아래 사진과 같이 새로 생성된 [,,,,"아이폰"] 키가 statle되지 않고 inactive 한 상태입니다.
해당 코드는 아래와 같습니다.
어떤 문제떄문에 발생하는 것이고, 해결방법은 무엇인가요?
Beta Was this translation helpful? Give feedback.
All reactions