Form
<Input label="time" name="time" /><Input label="timeUnit" name="timeUnit" />How to require input timeUnit when entering value into input time?
<Input label="time" name="time" /><Input label="timeUnit" name="timeUnit" />when method to add a condition to a field. The when method allows you to change the validation schema of a field based on the value of another field.timeUnit is required only if time is filled. If time is not filled, timeUnit is not required.

form?.getFieldValue("time") comes from Antd design and does not sync with UI.timeUnittimeUnitform?.getFieldValue("time")const schema = Yup.object().shape({
time: Yup.string()
.required('This field is required'),
timeUnit: Yup.string().when(
"time",
(time: string, schema: Yup.StringSchema) => {
return time ? schema.required('This field is required') : schema
}
),
});