VatsalDave2102 / react-ts-form-library

MIT License
0 stars 0 forks source link

feat: add useForm hook #1

Closed VatsalDave2102 closed 1 month ago

VatsalDave2102 commented 1 month ago

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)

feat: add validate field function, types of register options and validate rule (da3c11a)

test: add test cases for useForm hook (a327f3e)

Impact

This new hook will simplify form management in our React components, providing:

Usage Example


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>
);
github-actions[bot] commented 1 month ago

:tada: This PR is included in version 1.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: