NextJS Server Actions submit form from parent and sibling #775
-
Hi, I have followed and implemented the "next-server-actions" example but I am not 100% sure on why there is server and client validation as both show on the page if set. Is the point of the example to show that either can be used? Also is the "client-component.tsx" a 'use client' for the client validation so if not needed or wanted to be used then no need to the 'use client'? and also with the form onSubmit being handled by the form.handleSubmit() function is it possible to trigger this from a parent or sibling component? I as the last question because if not then whats the point as the whole page will have to be a 'use client' which defeats the whole purpose does it not? I am fully aware that I have missed the point completely and just don't understand. I am a little confused so any clarity and help would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
As maybe my initial post above was not clear or misleading. and to carry on from #710 the OP stated at the end of the thread just before it was closed the following "that is unclear to me is how to use the validated data after serverValidate, since it doesn't seem to be returned there." I have tried several different approaches to trigger a success method but I just dont have the intelligence or aptitude to do so. If anyone could help me out here then that would be amazing as I have spent one restless night and now two frustrating days smacking my head against my desk. |
Beta Was this translation helpful? Give feedback.
-
okay so it is simple as I expected it to be. I had tried this before but I guess i had something else broken at the time to make it break and not work. With ALL the examples that are not ssr related there is a onSubmit: async ({ value }) => { callback in useForm. I had assumed that this was not the way to do it as the ssr examples just dont have it present in the example. So yeah use the onSubmit callback for ssr implementations also.... |
Beta Was this translation helpful? Give feedback.
-
I think our DX in Next.js SSR could be improved. What do you think about this proposed DX? |
Beta Was this translation helpful? Give feedback.
I think our DX in Next.js SSR could be improved.
What do you think about this proposed DX?
#783