Next 15 useActionState and form actions / prevent unexpected submits #78128
Unanswered
Berzerk3000
asked this question in
Help
Replies: 2 comments 7 replies
-
|
Are you also using |
Beta Was this translation helpful? Give feedback.
5 replies
-
|
Did you solve this? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
So for a while now - in several Apps - I sometimes get an error message set in the outputted form html:
javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')to let next handle the formdata completely I usually use it like so :
and my formactions are usually something like this:
really nothing fancy I think. One thing I might add is that usually the flow for these apps is you load item data on pageload then pass it down to the form component bits and distribute defaultValues if present.
for most apps this seems to be no issue but for one I have odd behaviours happening and I think it might be tied to this .. silent error.
if the actionState is not meant to be used that way - what is the propper way then to react on action response? I have rooted out issues like button without a type etc.
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions