Created
October 20, 2021 03:25
-
-
Save Codennnn/536f754567e78f65db466611cab4b915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 创建表单 shouldUpdate 函数的简易工具方法 | |
* | |
* @param namePath - 要响应变化的表单字段,路径格式与调用 Form.getFieldValue 方法的传参一致 | |
*/ | |
export function shouldFormItemUpdate<Values>( | |
namePath: string | (string | number)[] | |
): (...value: [Values, Values]) => boolean { | |
const shouldUpdate = (...value: [Values, Values]) => { | |
const [prevValue, curValue] = value; | |
const pV = _get(prevValue, namePath); | |
const cV = _get(curValue, namePath); | |
return pV !== cV; | |
}; | |
return shouldUpdate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment