Replies: 1 comment
-
Shame on me. I totally missed it. https://next-safe-action.dev/docs/execution/hooks/hook-callbacks |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've just started with the library and it feels like I can't have the best of bost worlds (declarative and imperative) with this library.
If I go with the direct call option, then I lose the "isExecuting" to show a loading state (I have to manage my own loading state). If I go with the hook option (
useAction
) I get all the niceisExecuting
,isIdle
,hasErrored
,hasSuccedeed
which is very convenient and familiar for anyone that had used React-Query. The thing is, if I want to react to an error imperatively there's no way to do that at the moment. I mean, checking thehasErrored
and performing the action is not ideal, because the action might contain side effects and we would only want to trigger it once.React Query solves this by allowing us to set callbacks when declaring the mutation (see https://tanstack.com/query/v4/docs/framework/react/guides/mutations#mutation-side-effects).
It would be great if this library would allow us to do something similar, something like:
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions