How to properly re-submit mutateAsync() with the same values
The scenario is as follows:
- User submits a form with some values
- API returns an error
- Show the error message on the UI
- User submits the form again as it is. <- How to properly do this? Just calling the mutateAsync() again doesn't work.
Thank you! 🙏
3 Replies
fascinating-indigo•3y ago
why does it not work?
metropolitan-bronzeOP•3y ago
Thanks for the very quick response! I wasn't expecting it so fast. It looks like the issue I'm having is not related to TanStack Query, and is caused by something else in the UI.
I created a very simple example for both
useQuery and useMutation, which works as expected.
CodeSandbox link: https://codesandbox.io/s/tanstack-query-mxyfy8?file=/src/App.tsx
I should have started with the simplified example and not asked the question. Sorry for wasting your time!quietbits
CodeSandbox
tanstack-query - CodeSandbox
tanstack-query by quietbits using @tanstack/react-query, loader-utils, react, react-dom, react-scripts
fascinating-indigo•3y ago
Cool, thanks for being so honest and doing the work of making a minimal reproduction. Glad we could rule out react-query and I hope you find your problem