useForm Hook
Manage form state with validation
ReactFormsValidation
useForm
Form state management with validation
Copy source code and paste it in hooks/devsloka-hooks folder
hooks/devsloka-hooks/use-form.tsx
1"use client";2import { useState } from "react";34export const useForm = <T extends Record<string, unknown>>(5 initialValues: T6): [T, (e: React.ChangeEvent<HTMLInputElement>) => void] => {7 const [values, setValues] = useState<T>(initialValues);89 const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {10 setValues({11 ...values,12 [e.target.name]: e.target.value,13 });14 };1516 return [values, handleChange];17};