This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): use
react-hook-form
for validation
## what - use `react-hook-form` for validation - create interface type for form structure - use `zod` to build schema validation - use `zod` as validation resolver - set default value for `port number` - register form input to react-hook-form - ip address - port number - password - use `handleSubmit` from react-hook-form pass form values yo your own onSubmit function - extract `errors` from fromState to display validation error messages for their respective textfield ## how - check - https://www.youtube.com/playlist?list=PLC3y8-rFHvwjmgBr1327BA5bVXoQH-w5s - https://github.com/gopinav/React-Hook-Form-Tutorials/blob/main/rhf-demo/src/components/RHFYouTubeForm.tsx - https://github.com/gopinav/React-Hook-Form-Tutorials/blob/main/rhf-demo/src/components/ZodYouTubeForm.tsx ## why - simplifies form validation - less prone to bugs - less code ## where - ./src/components/LoginForm/index.tsx ## usage ## notes - resolves issue #754
- Loading branch information
1 parent
32b0499
commit 1ea8f34
Showing
1 changed file
with
181 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters