From f767898b6866126ac98d825dde92f0ad20a84683 Mon Sep 17 00:00:00 2001 From: Nadir Seghir Date: Mon, 9 Aug 2021 14:40:02 +0100 Subject: [PATCH] back to isBeforeProcessing --- .../components/text-input/validated-text-input.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/js/base/components/text-input/validated-text-input.tsx b/assets/js/base/components/text-input/validated-text-input.tsx index 49fd1005a4f..9ff893c255c 100644 --- a/assets/js/base/components/text-input/validated-text-input.tsx +++ b/assets/js/base/components/text-input/validated-text-input.tsx @@ -65,7 +65,7 @@ const ValidatedTextInput = ( { getValidationErrorId, } = useValidationContext(); - const { onCheckoutValidationBeforeProcessing } = useCheckoutContext(); + const { isBeforeProcessing } = useCheckoutContext(); const textInputId = typeof id !== 'undefined' ? id : 'textinput-' + instanceId; @@ -118,10 +118,10 @@ const ValidatedTextInput = ( { }, [ isPristine, setIsPristine, validateOnMount, validateInput ] ); useEffect( () => { - const unsubscribe = onCheckoutValidationBeforeProcessing( () => validateInput() ); - return unsubscribe; - }, [ onCheckoutValidationBeforeProcessing, validateInput ] ); - + if ( isBeforeProcessing ) { + validateInput(); + } + }, [ isBeforeProcessing, validateInput ] ); // Remove validation errors when unmounted. useEffect( () => { return () => {