Replies: 1 comment 3 replies
-
Hi @mobiixi36, As stated in mutation section This example is taken from the docs. import { useMutation, queryCache } from 'react-query'
// When this mutation succeeds, refetch any queries with the `todos` or `reminders` query key
const [mutate] = useMutation(addTodo, {
onSuccess: () => {
queryCache.refetchQueries('todos')
queryCache.refetchQueries('reminders')
},
})
mutate(todo)
// The 3 queries below will be refetched when the mutation above succeeds
const todoListQuery = useQuery('todos', fetchTodoList) All other most common use cases like updating query from the response returned from |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
All the example I saw about useQuery is when the page is loaded the data fetching starts. I wonder when to use
useQuery
and when to useuseMutation
?Beta Was this translation helpful? Give feedback.
All reactions