Skip to content

Commit 0ab8627

Browse files
committed
fix: Usage
1 parent 274dcd3 commit 0ab8627

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,33 @@ open http://localhost:8000
3333
## Usage
3434

3535
```js | pure
36-
import Form, { Field } from 'rc-field-form';
36+
import Form, { Field, useForm } from 'rc-field-form';
3737

38-
<Form
39-
onFinish={values => {
40-
console.log('Finish:', values);
41-
}}
42-
>
43-
<Field name="username">
44-
<Input placeholder="Username" />
45-
</Field>
46-
<Field name="password">
47-
<Input placeholder="Password" />
48-
</Field>
38+
const Input = ({ value = "", ...props }) => <input value={value} {...props} />;
4939

50-
<button>Submit</button>
51-
</Form>;
40+
const Demo = () => {
41+
const [form] = useForm();
42+
return (
43+
<Form
44+
form={form}
45+
onFinish={(values) => {
46+
console.log("Finish:", values);
47+
}}
48+
onValuesChange={(_, values) => {
49+
console.log("values:", values);
50+
}}
51+
>
52+
<Field name="username">
53+
<Input placeholder="Username" />
54+
</Field>
55+
<Field name="password">
56+
<Input placeholder="Password" />
57+
</Field>
58+
59+
<button>Submit</button>
60+
</Form>
61+
);
62+
};
5263

5364
export default Demo;
5465
```

0 commit comments

Comments
 (0)