我尝试在 checkAccountNumber 函数中从 antd 访问 Form.useWatch() 但收到此错误
钩子只能在函数组件的主体内部调用。
const getFieldValue = (fieldName,form) => {
return Form.useWatch(fieldName,form);
}
const checkAccountNumber = () => {
const accountNumber = getFieldValue("account_number", form)
if(isNumeric(accountNumber))
console.log("this true")
else
console.log("this is false");
}
Hooks 不能在函数内部调用。仅在组件中。
const checkAccountNumber = () => {
const accountNumber = Form.useWatch("account_number", form)
if(isNumeric(accountNumber))
console.log("this true")
else
console.log("this is false");
}