If the antd form component passes the axios api check?

for example, for some duplicate name checks, you need to go to the backend to get the results through axios. Since the antd check is triggered every time the input box is changed, frequently called network calls will have great performance problems. Is there any way to control the frequency of calls?

        validateDupName (name) {
           axios.get(/api-path/)..... api
        }
        
        <FormItem
          label=""
          {...formItemLayout}
        >
          {getFieldDecorator("name", {
            rules: [
              {
                validator: validateDupName
              }
            ],
          })(
            <Input placeholder=""/>
          )}
        </FormItem>
        
Jun.21,2021

debounce
although form is monitoring whether your input conforms to rule, you can still listen to the onChange event of this input, so bind the request method for backend verification in the onChange event of input. Then packed with debounce, the frequency can be controlled.
when your request returns a failure, you can call setFields , and add the form error of antd


first of all, the verification of antd input depends on the rules you set. This rules basically only verifies whether the specification is entered, and you need to verify whether the duplicate name can pass onBlur

.
Menu