mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 02:09:08 +03:00
fix: unregister field for lesson form
This commit is contained in:
parent
1b865c6df7
commit
07cb9494f5
@ -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<LessonFormPropsType> = ({
|
||||
register,
|
||||
watch,
|
||||
formState: { errors, isDirty },
|
||||
unregister,
|
||||
} = reactHookForm;
|
||||
|
||||
const [isLinkedVideoUrl, setIsLinkedVideoUrl] = useState<boolean>(false);
|
||||
|
||||
const watchDescription = watch('description');
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLinkedVideoUrl) {
|
||||
unregister('linked_video_url');
|
||||
}
|
||||
}, [isLinkedVideoUrl]);
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit}>
|
||||
<Stack spacing={'5'}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user