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 }, }; class App extends React.Component { formRef = React.createRef(); onGenderChange = (value: string) => { switch (value) { case 'male': this.formRef.current!.setFieldsValue({ note: 'Hi, man!' }); return; case 'female': this.formRef.current!.setFieldsValue({ note: 'Hi, lady!' }); return; case 'other': this.formRef.current!.setFieldsValue({ note: 'Hi there!' }); break; default: } }; onFinish = (values: any) => { console.log(values); }; onReset = () => { this.formRef.current!.resetFields(); }; onFill = () => { this.formRef.current!.setFieldsValue({ note: 'Hello world!', gender: 'male', }); }; render() { return (
prevValues.gender !== currentValues.gender} > {({ getFieldValue }) => getFieldValue('gender') === 'other' ? ( ) : null }
); } } export default App;