### What problem does this PR solve? fix: fetch user by @tanstack/react-query #1306 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
20 lines
502 B
TypeScript
20 lines
502 B
TypeScript
import { Form } from 'antd';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export const useValidateSubmittable = () => {
|
|
const [form] = Form.useForm();
|
|
const [submittable, setSubmittable] = useState<boolean>(false);
|
|
|
|
// Watch all values
|
|
const values = Form.useWatch([], form);
|
|
|
|
useEffect(() => {
|
|
form
|
|
.validateFields({ validateOnly: true })
|
|
.then(() => setSubmittable(true))
|
|
.catch(() => setSubmittable(false));
|
|
}, [form, values]);
|
|
|
|
return { submittable, form };
|
|
};
|