fix: Remove premature smsForm.resetFields() call to fix React warning
Fixed warning: 'Instance created by useForm is not connected to any Form element'
- Removed resetFields() call before form is rendered
- Form is only rendered when smsCodeSent === true
- Added preserve={false} to Form to ensure clean state
- Updated handleCancelSMS to only reset if form was rendered
Files:
- frontend/src/components/form/StepClaimConfirmation.tsx
This commit is contained in:
@@ -239,7 +239,8 @@ export default function StepClaimConfirmation({
|
||||
// Показываем модалку SMS-апрува
|
||||
setSmsModalVisible(true);
|
||||
setSmsCodeSent(false);
|
||||
smsForm.resetFields();
|
||||
// Не вызываем resetFields() здесь, т.к. форма еще не отрендерена
|
||||
// Форма будет сброшена при первом рендере
|
||||
|
||||
// Автоматически отправляем SMS-код
|
||||
sendSMSCode(phone);
|
||||
@@ -323,9 +324,12 @@ export default function StepClaimConfirmation({
|
||||
setSmsModalVisible(false);
|
||||
setSmsCodeSent(false);
|
||||
setPendingFormData(null);
|
||||
// Сбрасываем форму только если она была отрендерена (smsCodeSent был true)
|
||||
if (smsCodeSent) {
|
||||
smsForm.resetFields();
|
||||
}
|
||||
message.info('Подтверждение отменено');
|
||||
}, [smsForm]);
|
||||
}, [smsForm, smsCodeSent]);
|
||||
|
||||
// Вычисляем телефон для отображения (до условного рендера)
|
||||
const phone =
|
||||
@@ -412,6 +416,7 @@ export default function StepClaimConfirmation({
|
||||
form={smsForm}
|
||||
layout="vertical"
|
||||
onFinish={handleVerifyCode}
|
||||
preserve={false}
|
||||
>
|
||||
<Form.Item
|
||||
name="code"
|
||||
|
||||
Reference in New Issue
Block a user