mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 01:19:45 +08:00
27 lines
655 B
TypeScript
27 lines
655 B
TypeScript
|
import React from 'react';
|
||
|
import { Form, Input, InputNumber, Typography } from 'antd';
|
||
|
|
||
|
const Demo = () => {
|
||
|
const [form] = Form.useForm<{ name: string; age: number }>();
|
||
|
const nameValue = Form.useWatch('name', form);
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Form form={form} layout="vertical" autoComplete="off">
|
||
|
<Form.Item name="name" label="Name (Watch to trigger rerender)">
|
||
|
<Input />
|
||
|
</Form.Item>
|
||
|
<Form.Item name="age" label="Age (Not Watch)">
|
||
|
<InputNumber />
|
||
|
</Form.Item>
|
||
|
</Form>
|
||
|
|
||
|
<Typography>
|
||
|
<pre>Name Value: {nameValue}</pre>
|
||
|
</Typography>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default Demo;
|