HuolalaTech / react-query-kit

🕊️ A toolkit for ReactQuery that make ReactQuery hooks reusable and typesafe
MIT License
337 stars 11 forks source link

createMutation. Invalidate query in onSuccess callback #16

Closed pelevin-d-y closed 1 year ago

pelevin-d-y commented 1 year ago

How can I access queryClient to invalidate queries in onSuccess callback?

liaoliao666 commented 1 year ago

u can use option useDefaultOptions

createMutation({
  useDefaultOptions: () => {
    const queryClient = useQueryClient()
    return {
      onSuccess: () => {}
    }
  }
})