How to implement self-checking of forms on multiple modal pops up on the same page of ant design

is learning to use ant design"s modal and forms, and has encountered a problem.

what you want to achieve is that there are multiple buttons on the parent page that need to pop up their own Modal, and each Modal has its own Form, with its own validation content.

refer to the official example and write a code similar to the following

add NewOneA and NewOneB classes to the parent page:

saveAFormRef= (formRef) => {
        this.formRef = formRef;
}

saveBFormRef= (formRef) => {
        this.formRef = formRef;
}

render() {
    return(
        <NewOneA
            wrappedComponentRef={this.saveAFormRef}
            visible={visibleA}
            onCancel={this.handleCancelA}
            onOK={this.handleOKA}
        />
        <NewOneB
            wrappedComponentRef={this.saveBFormRef}
            visible={visibleB}
            onCancel={this.handleCancelB}
            onOK={this.handleOKB}
        />
    )
}

where NewOneA and NewOneB are forms in Modal
pseudo code:

<Modal
    visible={visible}
    title={title}
    onOk={onOK}
    onCancel={onCancel}
>
    <Form>
        <FormItem>
            {getFieldDecorator("author", {
               rules: [{ ... }],
            })(
               <Input />
            )}
        </FormItem>
    </Form>
</Modal>

because the formRef of NewOneA and NewOneB is stored in the same this.formRef in the parent page, the validateFields method cannot be used for verification correctly.

I tried to save formRef in two state, for example:

 this.setState({ AformRef: formRef });

but it doesn"t seem feasible to get a value from this.state.AformRef in other methods.

do you have any ideas to solve this problem?

Mar.15,2021

our company writes one component for each Modal, and verification is done in its own component.

handleSubmit = () => {
    let adopt = false;
    this.props.form.validateFields(
      (err) => {
        adopt = !err;
      },
    );
    if (adopt) {...}
  };

try it again, and the setState method should be feasible.
you can get the validateFields method by using
this.state.AformRef.props.form in other methods.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3af1d-2baa8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3af1d-2baa8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?