Skip to content
Discussion options

You must be logged in to vote

Two issues in this code that i can see:

  • remove the manual call to refetch. useQuery is smart enough to refetch automatically when you change the parameters passed to queryKey
  • instead of unwrapping your ref when calculating enabled do it via computed. When you access .value in that place, your are basically loosing reactivity, since this code is run only once. To get proper updates you should do something like this:
  const isEnabled = computed(() => payload.value.order_names.length > 0);
  const { data, error, isLoading, isSuccess, refetch } = useQuery({
    queryKey: ['update-order-name', order_id, payload],
    queryFn: fetchOrder,
    enabled: isEnabled,
    onSettled: (data, error) => 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Pranav-Bobde
Comment options

Answer selected by Pranav-Bobde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants