Use hooks to bind form components to actions such as uniform validation and get values.
npm install --save rc-form-hooks
import React from 'react'
import useForm from 'rc-form-hooks'
export default () => {
const { getFieldDecorator, validateFields } = useForm<{ username: string }>();
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
validateFields()
.then(console.log);
};
return (
<form onSubmit={handleSubmit}>
{getFieldDecorator('username')(
<input type="text"/>
)}
<button type={'submit'}>submit</button>
</form>
)
}
MIT © mushan0x0