https://github.com/mushan0x0/rc-form-hooks
Use hooks to bind form components to actions such as uniform validation and get values.
https://github.com/mushan0x0/rc-form-hooks
Last synced: 3 months ago
JSON representation
Use hooks to bind form components to actions such as uniform validation and get values.
- Host: GitHub
- URL: https://github.com/mushan0x0/rc-form-hooks
- Owner: mushan0x0
- License: mit
- Created: 2019-01-07T16:27:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T20:53:19.000Z (over 2 years ago)
- Last Synced: 2025-04-10T14:30:39.000Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.7 MB
- Stars: 59
- Watchers: 2
- Forks: 9
- Open Issues: 50
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rc-form-hooks
> Use hooks to bind form components to actions such as uniform validation and get values.
[](https://www.npmjs.com/package/rc-form-hooks) [](https://standardjs.com)
## Install
```bash
npm install --save rc-form-hooks
```or
```bash
yarn add rc-form-hooks
```## Usage
```tsx
import React from 'react';
import useForm from 'rc-form-hooks';export default () => {
const { getFieldDecorator, validateFields, errors, values } = useForm<{
username: string;
}>();
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
validateFields()
.then(console.log)
.catch(e => console.error(e.message));
};
return (
{getFieldDecorator('username', {
rules: [{ required: true, message: 'Please input username!' }]
})()}
{values.username}
{errors.username.message}
submit
);
};
```## License
MIT © [mushan0x0](https://github.com/mushan0x0)