NextJS Forms (useFormState, useStatus, useActionState) and Server actions
HTML-код
- Опубликовано: 17 сен 2024
- Table of Contents:
02:27 - setting up the project
09:51 - hyper ui components
17:36 - useFormStatus hook
22:09 - useFormState hook
28:40 - zod
01:08:10 - useActionState hook
#Link to source code on Github
github.com/eld...
Sir, Please make some more videos in nextjs
Coming right up
this is cool, im getting the hang of server actions. Also may i ask why dont u use react hook form? You made this project without using it. Can you tell me when to use it? in new RSC patterns
it is usually a matter of preference. You can use React Hook forms in place of plain native html forms. If you use these hooks in a component, it should be a client component. You can then import it in a server component
@@eldics so there's no reason to use react hook forms if i would validate in server ?
@@zhenobiikuzo4957it doesn’t matter. Validations can be done both on client side and server side. Even with server actions on your form, you can still do client side validations. One cool thing about server actions on forms is that validations can be made even if JavaScript is disabled on the client side.
@@eldics that seems like a better way tbh. too bad shadcn requires react hook form for that approach too.