Autosuggest component with useMutation or useQuery? #416
-
Hello! Please help me to understand how I'm must use 'react-query'. I need to create autosuggest component: when user input some value, component send request to server for suggestions and show it to user in dropdown. The user can enter the same text many times, and I would like to receive a response from the cache and not request it. I should used useMutation and queryCache instead of useQuery, right? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You should use |
Beta Was this translation helpful? Give feedback.
You should use
useQuery
and pass input value as query key variableTo avoid fetching suggestion for same input value too often - tune
useQuery
cacheTime
option