From 98922c8a68e1c4a4fdcfdce0ff24a8c45cb0a2c3 Mon Sep 17 00:00:00 2001 From: janrywang Date: Fri, 16 Apr 2021 16:08:01 +0800 Subject: [PATCH] feat(effects): normoalize onFieldInit --- packages/core/src/effects/onFieldEffects.ts | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/core/src/effects/onFieldEffects.ts b/packages/core/src/effects/onFieldEffects.ts index 8851c9b1f1d..9b0e820c947 100644 --- a/packages/core/src/effects/onFieldEffects.ts +++ b/packages/core/src/effects/onFieldEffects.ts @@ -28,7 +28,7 @@ function createFieldEffect( } ) } -const _onFieldInit = createFieldEffect(LifeCycleTypes.ON_FIELD_INIT) +export const onFieldInit = createFieldEffect(LifeCycleTypes.ON_FIELD_INIT) export const onFieldMount = createFieldEffect(LifeCycleTypes.ON_FIELD_MOUNT) export const onFieldUnmount = createFieldEffect(LifeCycleTypes.ON_FIELD_UNMOUNT) export const onFieldValueChange = createFieldEffect( @@ -53,20 +53,6 @@ export const onFieldValidateSuccess = createFieldEffect( LifeCycleTypes.ON_FIELD_VALIDATE_SUCCESS ) -export function onFieldInit( - pattern: FormPathPattern, - callback?: (field: GeneralField, form: Form) => void -) { - const form = useEffectForm() - const count = form.query(pattern).reduce((count, field) => { - callback(field, form) - return count + 1 - }, 0) - if (count === 0) { - _onFieldInit(pattern, callback) - } -} - export function onFieldReact( pattern: FormPathPattern, callback?: (field: GeneralField, form: Form) => void