How to handle after form submit with Server Actions ?

Hello, I'm looking for the best way to know the form is succesfully submitted and a succesful response returned. I know about useFormState which works by passing an inital state and then updating the state in the server action. But, here's the problem. const [formState, formAction] = useFormState(editProvider, {success:null}); formState?.success // true after first response Form submitted, success is true. If you submit the form again success is still true so the state isnt updated. I want to close the dialog when the success is true even after resubmissions. How I can handle this without disabling progressive enhancement ?
1 Reply
Efkan
EfkanOP14mo ago
For now, I solved this with returning a random id from the action so checking that random id like formState.id inside useEffect solves the problem but this is very ugly
Want results from more Discord servers?
Add your server