useMutation onError behavior
Hey there,
I'm freaking out here. I'm sending a POST using
useMutation , and if the API returns any errors I call setErrors inside onError callback. But I don't understand why setErrors is only being updated when I click in the Submit Button for the 2nd time.
Hook:
3 Replies
flat-fuchsiaOP•4y ago
Or, shouldn't I add errors in state and use it from react-query? :sus:
I'm still diving into abstract the states in my mind.
eastern-cyan•4y ago
why do you need to call
setErrors ? useMutation returns the errors directly, next to the isLoading state and the mutate function ...
also, what's this?
this violates the rules of hooks? 🙃flat-fuchsiaOP•4y ago
yes, I notice that right now, I actually call the mutate there, but I wrote the hook by accident.
I'm suffering from terminal stupidity :eheh: