Im trying to create a custom Hook with useMutation
this is my custom hook which im exporting into my
todo component, i want to call mutate on the hook via a button click. but the hook returns a promise and mutate is no available, can anyone help?
hook
todo component
10 Replies
adverse-sapphire•4y ago
Remove the async on the function defining the hook ?
wise-whiteOP•4y ago
okay ill do that
wise-whiteOP•4y ago


wise-whiteOP•4y ago
figured it out
optimistic-gold•4y ago
you can't call the hook in the click handler. You need to call the hook at the top level, then invoke
mutate onClickwise-whiteOP•4y ago
this worked, but is there a better way of doing this?
wise-whiteOP•4y ago

wise-whiteOP•4y ago
thank you for all the help
optimistic-gold•4y ago
what would you need to be "better" ? this is the way 🙂
wise-whiteOP•4y ago
nothing at all, you are right.