Closed VatsalDave2102 closed 1 month ago
This PR introduces a new useForm hook for managing form state and validation in React applications.
useForm
register
handleSubmit
validateField
RegisterOptions
ValidationRule
This new hook will simplify form management in our React components, providing:
const { register, handleSubmit, errors, values } = useForm<FormData>(); const onSubmit = (data: FormData) => { // Handle form submission }; return ( <form onSubmit={handleSubmit(onSubmit)}> <input {...register("email", { required: true, pattern: /^\S+@\S+$/i })} /> {errors.email && <span>{errors.email}</span>} <button type="submit">Submit</button> </form> );
:tada: This PR is included in version 1.1.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Add useForm Hook with Validation
This PR introduces a new
useForm
hook for managing form state and validation in React applications.Changes
feat: add useForm hook (b1a6ea3)
useForm
hookregister
andhandleSubmit
functionsfeat: add validate field function, types of register options and validate rule (da3c11a)
validateField
function for individual field validationRegisterOptions
andValidationRule
register
function to accept validation optionstest: add test cases for useForm hook (a327f3e)
useForm
hookImpact
This new hook will simplify form management in our React components, providing:
Usage Example