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>
<Radio value={'xxx'}>xxx</Radio>
</Radio.Group>
</Form.Item>
)
}
</Form.Item>
<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="b" label="b方式" required rules={[
({ getFieldValue }) => ({
validator(_, value) {
// 依赖a
console.log('validate);
},
})]}>
<Radio.Group disabled={disabled}>
<Radio value={'ddd'}>ddd</Radio>
<Radio value={'xxx'}>xxx</Radio>
</Radio.Group>
</Form.Item>
)
}
</Form.Item>