Medium
Complete the missing code in this custom form validation hook:
1function useFormValidation(initialState) {2 const [values, setValues] = useState(initialState);3 const [errors, setErrors] = useState({});4 const [isSubmitting, setIsSubmitting] = useState(false);56 useEffect(() => {7 if (isSubmitting) {8 ________________________9 ________________________10 ________________________11 }12 }, [values, isSubmitting]);1314 function handleChange(event) {15 const { name, value } = event.target;16 setValues(prev => ({17 ...prev,18 [name]: value19 }));20 }2122 function handleSubmit(event) {23 event.preventDefault();24 setErrors(validate(values));25 setIsSubmitting(true);26 }2728 return {29 values,30 errors,31 handleChange,32 handleSubmit,33 isSubmitting34 };35}