import { useState, useEffect } from 'react'; import BtnGroup from "../Buttons/BtnGroup"; import styles from "./form.module.scss"; const SubjectForm = () => { const [subject, setSubject] = useState({ lectureName: "", prof: "", classRoom: "" }) const [disabled, setDisabled] = useState(true) useEffect(() => { let isMounted = true; const checkInfo = { lectureName: subject.lectureName, prof: subject.prof, classRoom: subject.classRoom } if (isMounted) { const isSubject = Object.values(checkInfo).every((el) => Boolean(el)); isSubject ? setDisabled(false) : setDisabled(true); } return () => { isMounted = false; } }, [subject]) function handleChange(e) { const { name, value } = e.target setSubject({ ...subject, [name]: value }) } return ( <>
) } export default SubjectForm;