The Antd form component is rewritten with React Hooks. How do I get the value of the form?

the Antd form component is rewritten with React Hooks. How do I get the value of the form? For example, TextareaItem component of antd-mobile, and
rewrite it with React Hooks. The semi-finished code is as follows:

import React, { useState, useEffect} from "react"
import { List, TextareaItem } from "antd-mobile";
import { createForm } from "rc-form";


function TextareaItemExample {

  useEffect(() => {
    //this.autoFocusInst.focus();
  });

  return (
    <div>
      <List renderHeader={() => "Customize to focus"}>
        <TextareaItem
          title="title"
          placeholder="auto focus in Alipay client"
          data-seed="logId"
          ref={el => this.autoFocusInst = el}
          autoHeight
        />
        <TextareaItem
          title="content"
          placeholder="click the button below to focus"
          data-seed="logId"
          autoHeight
        />
      </List>
    </div>
  );
}

const TextareaItemExampleWrapper = createForm()(TextareaItemExample);

export default TextareaItemExampleWrapper;


question:
1, how to get the value of the form? Get the value so that it can be used to send ajax requests. There is a custom Hook library react-use-form-state , but it is used for native html forms. How can you do the same thing on antd forms?

2. How should the statement this.autoFocusInst.focus (); be written after the class component is changed to a function component?

Mar.08,2022

https://github.com/mushan0x0/. uses this library, supports antd or antd-m checking, full ts prompts, and even native form tags support


1.antd forms to specify a field using getFieldDecorator two-way binding and use this.props.form.validateFields or this.props.form.getFieldsValue to get the value of the form.
2. Try useRef


. Have you solved the problem

?
Menu