What is the proper type for this Form Submit event?
Answered
sh1ro posted this in #help-forum
sh1roOP
I get a TypeError on the
<Form>
component. I don't know what should I use to define the handleSubmit
function's e
? Sorry, I'm new to NextJS's <Form>
.Answered by Asian black bear
Use a normal
form
element then. The new next/form
is only for very specific use-cases, not really one where you pass a client-side handler.14 Replies
Asian black bear
Ctrl + Left Click on
action
and your editor should bring you to the type definition of action
.@Asian black bear Ctrl + Left Click on `action` and your editor should bring you to the type definition of `action`.
sh1roOP
I did use that feature. But anything I changed to seem invalid to the attribute.
I have no idea about this actually.
Asian black bear
Even hovering over it shows it clearly - you can see it's a function that takes
FormData
.@Asian black bear Even hovering over it shows it clearly - you can see it's a function that takes `FormData`.
sh1roOP
But if I changed it to
<FormData>
, I can’t use e.target.value
. Any suggestion?Asian black bear
Use a normal
form
element then. The new next/form
is only for very specific use-cases, not really one where you pass a client-side handler.Answer
Asian black bear
It is designed to be a lightweight form element or one that takes a server action and makes it progressively enhanced etc.
If you run client-side code, none of that matters.
sh1roOP
So my use case isn’t making any sense to the
<Form>
’s rule and design?Asian black bear
If you can't make use of progressive enhancement, prefetching etc. then no.
@Asian black bear If you can't make use of progressive enhancement, prefetching etc. then no.
sh1roOP
Well then, thanks for helping me. I'm using the
form
instead as you advise me to, and it just works fine as usual.