Reset the state of useActionState #75365
Replies: 2 comments 1 reply
-
May I ask, why do you need to reset it? that state value is whatever your action returned last. Resetting it, feels unnecessary in the use case you shared. |
Beta Was this translation helpful? Give feedback.
-
I'm having a similar issue where I'm incrementing a value in an effect or displaying an error based on whether the action was a success or not. It's causing an infinite loop and I haven't found a nice way around it. Setting It would be nicer to be able to reset the state once the response has been handled, since the form is being used in a component that stays mounted and the form itself is reset each time it is submitted. |
Beta Was this translation helpful? Give feedback.
-
Summary
Is there a way to reset the state of the useActionState? I'm using the state like the example below, and once the
deleteDate.success
turns to true, it stays there. Is there a way to turn it back? The only way I found is thisdeleteState.success = false; // Reset success state
, but I'm not sure if that's a bad way to go about it.Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions