diff --git a/src/components/Forms/LessonForm/LessonForm.tsx b/src/components/Forms/LessonForm/LessonForm.tsx index 669a687..36e7dd5 100644 --- a/src/components/Forms/LessonForm/LessonForm.tsx +++ b/src/components/Forms/LessonForm/LessonForm.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { FormControl, FormHelperText, @@ -52,12 +52,19 @@ const LessonForm: React.FC = ({ register, watch, formState: { errors, isDirty }, + unregister, } = reactHookForm; const [isLinkedVideoUrl, setIsLinkedVideoUrl] = useState(false); const watchDescription = watch('description'); + useEffect(() => { + if (!isLinkedVideoUrl) { + unregister('linked_video_url'); + } + }, [isLinkedVideoUrl]); + return (