import React from 'react'; import { Button, Form, Input, Select } from 'antd'; import type { FormInstance } from 'antd/es/form'; const { Option } = Select; const layout = { labelCol: { span: 8 }, wrapperCol: { span: 16 }, }; const tailLayout = { wrapperCol: { offset: 8, span: 16 }, }; const App: React.FC = () => { const formRef = React.useRef(null); const onGenderChange = (value: string) => { switch (value) { case 'male': formRef.current?.setFieldsValue({ note: 'Hi, man!' }); break; case 'female': formRef.current?.setFieldsValue({ note: 'Hi, lady!' }); break; case 'other': formRef.current?.setFieldsValue({ note: 'Hi there!' }); break; default: break; } }; const onFinish = (values: any) => { console.log(values); }; const onReset = () => { formRef.current?.resetFields(); }; const onFill = () => { formRef.current?.setFieldsValue({ note: 'Hello world!', gender: 'male' }); }; return (
prevValues.gender !== currentValues.gender} > {({ getFieldValue }) => getFieldValue('gender') === 'other' ? ( ) : null }
); }; export default App;