File tree Expand file tree Collapse file tree 1 file changed +25
-14
lines changed Expand file tree Collapse file tree 1 file changed +25
-14
lines changed Original file line number Diff line number Diff 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
5364export default Demo ;
5465```
You can’t perform that action at this time.
0 commit comments