import React, { useEffect, useState } from 'react'; import { Button, Checkbox, Form, Input } from 'antd'; const formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 8 }, }; const formTailLayout = { labelCol: { span: 4 }, wrapperCol: { span: 8, offset: 4 }, }; const App: React.FC = () => { const [form] = Form.useForm(); const [checkNick, setCheckNick] = useState(false); useEffect(() => { form.validateFields(['nickname']); }, [checkNick, form]); const onCheckboxChange = (e: { target: { checked: boolean } }) => { setCheckNick(e.target.checked); }; const onCheck = async () => { try { const values = await form.validateFields(); console.log('Success:', values); } catch (errorInfo) { console.log('Failed:', errorInfo); } }; return (
Nickname is required
); }; export default App;