From f84dcf437d3bb369fe3bd78dfc5c9af2d1fbe092 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 19 Mar 2024 12:46:10 +0530 Subject: [PATCH 1/2] chore: useCallback changes from 0-7 to useCallback --- src/Components/AddressPaymentInput.res | 2 +- src/Components/BillingNamePaymentInput.res | 2 +- src/Components/BlikCodePaymentInput.res | 2 +- src/Components/EmailPaymentInput.res | 2 +- src/Components/FullNamePaymentInput.res | 2 +- src/Components/PortalCapture.res | 2 +- src/Components/SavedMethods.res | 2 +- src/Hooks/OutsideClick.res | 4 ++-- src/PaymentElement.res | 2 +- src/Payments/ACHBankDebit.res | 2 +- src/Payments/ACHBankTransfer.res | 2 +- src/Payments/BacsBankTransfer.res | 2 +- src/Payments/BecsBankDebit.res | 2 +- src/Payments/Boleto.res | 2 +- src/Payments/CardPayment.res | 2 +- src/Payments/KlarnaPayment.res | 2 +- src/Payments/PaymentMethodsWrapper.res | 2 +- src/Payments/SepaBankDebit.res | 2 +- src/Payments/SepaBankTransfer.res | 2 +- src/Utilities/DynamicFieldsUtils.res | 2 +- 20 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Components/AddressPaymentInput.res b/src/Components/AddressPaymentInput.res index 493a6f061..80258f6b3 100644 --- a/src/Components/AddressPaymentInput.res +++ b/src/Components/AddressPaymentInput.res @@ -166,7 +166,7 @@ let make = (~paymentType, ~className="") => { None }, [country.value]) - let submitCallback = React.useCallback6((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Components/BillingNamePaymentInput.res b/src/Components/BillingNamePaymentInput.res index 2676f82bd..d92abd5fc 100644 --- a/src/Components/BillingNamePaymentInput.res +++ b/src/Components/BillingNamePaymentInput.res @@ -37,7 +37,7 @@ let make = (~paymentType, ~customFieldName=None, ~requiredFields as optionalRequ } let nameRef = React.useRef(Nullable.null) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Components/BlikCodePaymentInput.res b/src/Components/BlikCodePaymentInput.res index ced845885..c58d4fc7c 100644 --- a/src/Components/BlikCodePaymentInput.res +++ b/src/Components/BlikCodePaymentInput.res @@ -40,7 +40,7 @@ let make = () => { None }, [blikCode.isValid]) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Components/EmailPaymentInput.res b/src/Components/EmailPaymentInput.res index 2688b6c93..422cf62a5 100644 --- a/src/Components/EmailPaymentInput.res +++ b/src/Components/EmailPaymentInput.res @@ -40,7 +40,7 @@ let make = (~paymentType) => { None }, [email.isValid]) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Components/FullNamePaymentInput.res b/src/Components/FullNamePaymentInput.res index 975c12568..04ad9df4c 100644 --- a/src/Components/FullNamePaymentInput.res +++ b/src/Components/FullNamePaymentInput.res @@ -35,7 +35,7 @@ let make = (~paymentType, ~customFieldName=None, ~optionalRequiredFields=None) = } let nameRef = React.useRef(Nullable.null) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Components/PortalCapture.res b/src/Components/PortalCapture.res index 568afa946..ad314a581 100644 --- a/src/Components/PortalCapture.res +++ b/src/Components/PortalCapture.res @@ -1,7 +1,7 @@ @react.component let make = React.memo((~name: string) => { let (_, setPortalNodes) = Recoil.useRecoilState(RecoilAtoms.portalNodes) - let setDiv = React.useCallback2((elem: Nullable.t) => { + let setDiv = React.useCallback((elem: Nullable.t) => { setPortalNodes( prevDict => { let clonedDict = diff --git a/src/Components/SavedMethods.res b/src/Components/SavedMethods.res index 29e63259e..c7464756f 100644 --- a/src/Components/SavedMethods.res +++ b/src/Components/SavedMethods.res @@ -71,7 +71,7 @@ let make = ( } let empty = cvcNumber == "" - let submitCallback = React.useCallback4((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper let (token, customerId) = paymentToken diff --git a/src/Hooks/OutsideClick.res b/src/Hooks/OutsideClick.res index 03ccb298a..4a8d38380 100644 --- a/src/Hooks/OutsideClick.res +++ b/src/Hooks/OutsideClick.res @@ -21,9 +21,9 @@ let useOutsideClick = ( None }, [callback]) - React.useCallback0(() => { + React.useCallback(() => { callbackRef.current() - }) + }, []) } let eventCallback = useEvent0(callback) React.useEffect1(() => { diff --git a/src/PaymentElement.res b/src/PaymentElement.res index cb1dc8a4d..02cbd090f 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -216,7 +216,7 @@ let make = ( let cardShimmerCount = React.useMemo1(() => { cardsToRender(cardsContainerWidth) }, [cardsContainerWidth]) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit && selectedOption == "" { diff --git a/src/Payments/ACHBankDebit.res b/src/Payments/ACHBankDebit.res index 978e93a87..5a1421172 100644 --- a/src/Payments/ACHBankDebit.res +++ b/src/Payments/ACHBankDebit.res @@ -55,7 +55,7 @@ let make = (~paymentType: CardThemeType.mode, ~list: PaymentMethodsRecord.list) None }, (empty, complete)) - let submitCallback = React.useCallback3((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper diff --git a/src/Payments/ACHBankTransfer.res b/src/Payments/ACHBankTransfer.res index c45bf9be0..6774f2e51 100644 --- a/src/Payments/ACHBankTransfer.res +++ b/src/Payments/ACHBankTransfer.res @@ -23,7 +23,7 @@ let make = (~paymentType: CardThemeType.mode, ~list: PaymentMethodsRecord.list) None }, [complete]) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Payments/BacsBankTransfer.res b/src/Payments/BacsBankTransfer.res index f1e7043b0..d73a0e183 100644 --- a/src/Payments/BacsBankTransfer.res +++ b/src/Payments/BacsBankTransfer.res @@ -28,7 +28,7 @@ let default = (props: props) => { None }, [complete]) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Payments/BecsBankDebit.res b/src/Payments/BecsBankDebit.res index 3323a6fe0..eb39cd7ee 100644 --- a/src/Payments/BecsBankDebit.res +++ b/src/Payments/BecsBankDebit.res @@ -53,7 +53,7 @@ let make = (~paymentType: CardThemeType.mode, ~list: PaymentMethodsRecord.list) None }, [complete]) - let submitCallback = React.useCallback3((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Payments/Boleto.res b/src/Payments/Boleto.res index 6dd4c0992..b0ea48eb3 100644 --- a/src/Payments/Boleto.res +++ b/src/Payments/Boleto.res @@ -54,7 +54,7 @@ let make = (~paymentType: CardThemeType.mode, ~list: PaymentMethodsRecord.list) None }, [complete]) - let submitCallback = React.useCallback1((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res index fb523f017..daca89438 100644 --- a/src/Payments/CardPayment.res +++ b/src/Payments/CardPayment.res @@ -111,7 +111,7 @@ let make = ( } }, (isSaveCardsChecked, list.payment_type)) - let submitCallback = React.useCallback6((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper let (month, year) = CardUtils.getExpiryDates(cardExpiry) diff --git a/src/Payments/KlarnaPayment.res b/src/Payments/KlarnaPayment.res index 0a7cd5d91..9e47c576b 100644 --- a/src/Payments/KlarnaPayment.res +++ b/src/Payments/KlarnaPayment.res @@ -39,7 +39,7 @@ let make = (~paymentType, ~countryProps, ~list: PaymentMethodsRecord.list) => { None }, [complete]) - let submitCallback = React.useCallback3((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper let (connectors, _) = list->PaymentUtils.getConnectors(PayLater(Klarna(Redirect))) diff --git a/src/Payments/PaymentMethodsWrapper.res b/src/Payments/PaymentMethodsWrapper.res index be0d10ab4..43a1b6b61 100644 --- a/src/Payments/PaymentMethodsWrapper.res +++ b/src/Payments/PaymentMethodsWrapper.res @@ -62,7 +62,7 @@ let make = ( None }, (empty, complete)) - let submitCallback = React.useCallback7((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Payments/SepaBankDebit.res b/src/Payments/SepaBankDebit.res index 461c2549f..ae725072a 100644 --- a/src/Payments/SepaBankDebit.res +++ b/src/Payments/SepaBankDebit.res @@ -47,7 +47,7 @@ let make = (~paymentType: CardThemeType.mode, ~list: PaymentMethodsRecord.list) None }, [complete]) - let submitCallback = React.useCallback3((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper diff --git a/src/Payments/SepaBankTransfer.res b/src/Payments/SepaBankTransfer.res index 9c671e4c2..c9fdf201a 100644 --- a/src/Payments/SepaBankTransfer.res +++ b/src/Payments/SepaBankTransfer.res @@ -37,7 +37,7 @@ let make = ( None }, [complete]) - let submitCallback = React.useCallback3((ev: Window.event) => { + let submitCallback = React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index 01c89feb2..6dcd87886 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -662,7 +662,7 @@ let useSubmitCallback = () => { let {localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) - React.useCallback5((ev: Window.event) => { + React.useCallback((ev: Window.event) => { let json = ev.data->JSON.parseExn let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper if confirm.doSubmit { From d33105fb5c1759edead61fb31abe2305f5236ef0 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 19 Mar 2024 20:06:40 +0530 Subject: [PATCH 2/2] fix: callback0 changes --- src/Hooks/OutsideClick.res | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Hooks/OutsideClick.res b/src/Hooks/OutsideClick.res index 4a8d38380..03ccb298a 100644 --- a/src/Hooks/OutsideClick.res +++ b/src/Hooks/OutsideClick.res @@ -21,9 +21,9 @@ let useOutsideClick = ( None }, [callback]) - React.useCallback(() => { + React.useCallback0(() => { callbackRef.current() - }, []) + }) } let eventCallback = useEvent0(callback) React.useEffect1(() => {