Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antd的form的shouldUpdate执行了validator没有执行 #587

Open
nkli opened this issue May 12, 2023 · 1 comment
Open

antd的form的shouldUpdate执行了validator没有执行 #587

nkli opened this issue May 12, 2023 · 1 comment

Comments

@nkli
Copy link

nkli commented May 12, 2023

a和b的校验都相互依赖,这里用shouldUpdate去做,结果shouldUpdate执行了,对应的validator没有执行。这种应该怎么处理?
<Form.Item
noStyle
shouldUpdate={(pre: any, current: any) => {
const result = JSON.stringify(pre.a) !== JSON.stringify(current.a)
|| JSON.stringify(pre.b) !== JSON.stringify(current.b);
console.log('shouldUpdate', result);
return result;
}}
>
{
() => (
<Form.Item name="a" label="a方式" required rules={[
({ getFieldValue }) => ({
validator(_, value) {
// 依赖b
console.log('validate);
},
})]}>
<Radio.Group disabled={disabled}>
<Radio value={'ddd'}>ddd
<Radio value={'xxx'}>xxx
</Radio.Group>
</Form.Item>
)
}
</Form.Item>

@1075488066
Copy link

为什么不直接用denpends不是更简单吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants