Using pending & error states with createRouteAction

I'm writing a handleSubmit function that, assuming the post request goes through, a user will be navigated to the next page. My function looks like the following:
const handleSumbit = async() => {
await doThisAction()
if (doingThisAction.pending && !doingThisAction.error) {
// navigate to next page
}
}
const handleSumbit = async() => {
await doThisAction()
if (doingThisAction.pending && !doingThisAction.error) {
// navigate to next page
}
}
The issue I'm running into at the moment is that both values are immediately evaluated to be truthy and you're navigated to the next page, before getting a response. Is there a better way to approach this?
2 Replies
bigmistqke
bigmistqke11mo ago
Could you elaborate what doThisAction and doingThisAction are?
Lady Bluenotes
Lady Bluenotes11mo ago
They're the tuple for the createRouteAction where doingThisAction is the first value and doThisAction is the second value Oo thank you!
Want results from more Discord servers?
Add your server