Antd表单组件用React Hooks重写,怎么获取表单的值?比如antd-mobile的TextareaItem组件,
用React Hooks重写它,半成品代码如下:
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;
问题:
1、怎么获取表单的值?获取值后好用于发送ajax请求。这里有个自定义Hook库react-use-form-state,但是它用于原生html表单,怎么在antd表单上做同样的事?
2、 class组件改成function组件后, this.autoFocusInst.focus();
这个语句应该怎么写?
https://github.com/mushan0x0/... 使用这个库,支持antd或者antd-m校验,全ts提示,就算是原生的form标签也支持