Skip to content

Commit

Permalink
chore: useMemo changes from 0-7 to useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Mar 19, 2024
1 parent fa0d522 commit 9385f31
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ let make = () => {
let paymentMode = CardUtils.getQueryParamsDictforKey(url.search, "componentName")
let fullscreenMode = CardUtils.getQueryParamsDictforKey(url.search, "fullscreenType")

let logger = React.useMemo0(() => {
let logger = React.useMemo(() => {
let log = OrcaLogger.make()
log
})
}, [])

React.useEffect1(() => {
setLoggerState(_ => logger)
Expand Down
2 changes: 1 addition & 1 deletion src/CardUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ let setRightIconForCvc = (~cardEmpty, ~cardInvalid, ~color, ~cardComplete) => {
}

let useCardDetails = (~cvcNumber, ~isCvcValidValue, ~isCVCValid) => {
React.useMemo3(() => {
React.useMemo(() => {
let isCardDetailsEmpty = String.length(cvcNumber) == 0
let isCardDetailsValid = isCvcValidValue == "valid"
let isCardDetailsInvalid = isCvcValidValue == "invalid"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Accordion.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let make = (
accordionItemLabelClass,
accordionItemIconClass,
radioClass,
) = React.useMemo1(
) = React.useMemo(
() =>
isActive
? (
Expand Down
2 changes: 1 addition & 1 deletion src/Components/DropdownField.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let make = (
let value = target["value"]
setValue(value)
}
let disbaledBG = React.useMemo1(() => {
let disbaledBG = React.useMemo(() => {
themeObj.colorBackground
}, [themeObj])
React.useEffect0(() => {
Expand Down
12 changes: 6 additions & 6 deletions src/Components/DynamicFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let make = (
~paymentMethodType,
)

let requiredFieldsWithBillingDetails = React.useMemo3(() => {
let requiredFieldsWithBillingDetails = React.useMemo(() => {
if paymentMethod === "card" {
paymentMethodTypes.required_fields
} else if (
Expand All @@ -39,18 +39,18 @@ let make = (
}
}, (paymentMethod, paymentMethodTypes.required_fields, paymentMethodType))

let requiredFields = React.useMemo1(() => {
let requiredFields = React.useMemo(() => {
requiredFieldsWithBillingDetails->DynamicFieldsUtils.removeBillingDetailsIfUseBillingAddress(
billingAddress,
)
}, [requiredFieldsWithBillingDetails])

let isAllStoredCardsHaveName = React.useMemo1(() => {
let isAllStoredCardsHaveName = React.useMemo(() => {
PaymentType.getIsAllStoredCardsHaveName(savedCards)
}, [savedCards])

//<...>//
let fieldsArr = React.useMemo3(() => {
let fieldsArr = React.useMemo(() => {
PaymentMethodsRecord.getPaymentMethodFields(
paymentMethodType,
requiredFields,
Expand Down Expand Up @@ -257,11 +257,11 @@ let make = (
}
}

let dynamicFieldsToRenderOutsideBilling = React.useMemo1(() => {
let dynamicFieldsToRenderOutsideBilling = React.useMemo(() => {
fieldsArr->Array.filter(DynamicFieldsUtils.isFieldTypeToRenderOutsideBilling)
}, [fieldsArr])

let dynamicFieldsToRenderInsideBilling = React.useMemo1(() => {
let dynamicFieldsToRenderInsideBilling = React.useMemo(() => {
fieldsArr->Array.filter(field => !(field->DynamicFieldsUtils.isFieldTypeToRenderOutsideBilling))
}, [fieldsArr])

Expand Down
2 changes: 1 addition & 1 deletion src/Components/InputField.res
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let make = (

let isValidValue = CardUtils.getBoolOptionVal(isValid)

let (cardEmpty, cardComplete, cardInvalid, cardFocused) = React.useMemo5(() => {
let (cardEmpty, cardComplete, cardInvalid, cardFocused) = React.useMemo(() => {
let isCardDetailsEmpty =
String.length(value) == 0
? `${options.classes.base} ${options.classes.empty} `
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Modal.res
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let make = (
}, [loader])

let loaderVisibility = loader ? "visible" : "hidden"
let contentVisibility = React.useMemo1(() => {
let contentVisibility = React.useMemo(() => {
!openModal ? "hidden" : "visible"
}, [openModal])

Expand Down
2 changes: 1 addition & 1 deletion src/Components/PaymentDropDownField.res
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ let make = (
errorString: "",
})
}
let disbaledBG = React.useMemo1(() => {
let disbaledBG = React.useMemo(() => {
themeObj.colorBackground
}, [themeObj])
let cursorClass = !disabled ? "cursor-pointer" : "cursor-not-allowed"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/SurchargeUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let useSurchargeDetailsForOneClickWallets = (~list) => {
RecoilAtoms.areOneClickWalletsRendered,
)

React.useMemo2(() => {
React.useMemo(() => {
oneClickWallets->Array.reduce([], (acc, wallet) => {
let isWalletBtnRendered = switch wallet.paymentMethodType {
| "apple_pay" => areOneClickWalletsRendered.isApplePay
Expand Down
2 changes: 1 addition & 1 deletion src/Hooks/UtilityHooks.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let useIsGuestCustomer = () => {
let {customerPaymentMethods} = RecoilAtoms.optionAtom->Recoil.useRecoilValueFromAtom

React.useMemo1(() => {
React.useMemo(() => {
switch customerPaymentMethods {
| LoadedSavedCards(_, false)
| NoResult(false) => false
Expand Down
4 changes: 2 additions & 2 deletions src/Payment.res
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
let (isCVCValid, setIsCVCValid) = React.useState(_ => None)
let (isZipValid, setIsZipValid) = React.useState(_ => None)

let (cardBrand, maxCardLength) = React.useMemo3(() => {
let (cardBrand, maxCardLength) = React.useMemo(() => {
let brand = getCardBrand(cardNumber)
let maxLength = getMaxLength(cardNumber)
let isNotBancontact = selectedOption !== "bancontact_card" && brand == ""
Expand Down Expand Up @@ -166,7 +166,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
}
}

let handleElementFocus = React.useMemo4(() => {
let handleElementFocus = React.useMemo(() => {
isFocus => {
setIsFocus(_ => isFocus)
}
Expand Down
4 changes: 2 additions & 2 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ let make = (
~paymentMethodType="apple_pay",
)

let (walletList, paymentOptionsList, actualList) = React.useMemo6(() => {
let (walletList, paymentOptionsList, actualList) = React.useMemo(() => {
switch methodslist {
| Loaded(paymentlist) =>
let paymentOrder =
Expand Down Expand Up @@ -213,7 +213,7 @@ let make = (
}
None
}, (cardsContainerWidth, paymentOptions))
let cardShimmerCount = React.useMemo1(() => {
let cardShimmerCount = React.useMemo(() => {
cardsToRender(cardsContainerWidth)
}, [cardsContainerWidth])
let submitCallback = React.useCallback1((ev: Window.event) => {
Expand Down
6 changes: 3 additions & 3 deletions src/Payments/ApplePay.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let make = (
let isWallet = walletOptions->Array.includes("apple_pay")
let areOneClickWalletsRendered = Recoil.useSetRecoilState(RecoilAtoms.areOneClickWalletsRendered)

let applePayPaymentMethodType = React.useMemo1(() => {
let applePayPaymentMethodType = React.useMemo(() => {
switch PaymentMethodsRecord.getPaymentMethodTypeFromList(
~list,
~paymentMethod="wallet",
Expand All @@ -37,14 +37,14 @@ let make = (
}
}, [list])

let paymentExperience = React.useMemo1(() => {
let paymentExperience = React.useMemo(() => {
switch applePayPaymentMethodType.payment_experience[0] {
| Some(paymentExperience) => paymentExperience.payment_experience_type
| None => PaymentMethodsRecord.RedirectToURL
}
}, [applePayPaymentMethodType])

let isInvokeSDKFlow = React.useMemo1(() => {
let isInvokeSDKFlow = React.useMemo(() => {
paymentExperience == PaymentMethodsRecord.InvokeSDK && isApplePaySDKFlow
}, [sessionObj])

Expand Down
2 changes: 1 addition & 1 deletion src/Payments/BankTransfersPopup.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let make = (~transferType) => {

let (isCopied, setIsCopied) = React.useState(_ => false)
let (openModal, setOpenModal) = React.useState(_ => false)
let (buttonElement, text) = React.useMemo1(() => {
let (buttonElement, text) = React.useMemo(() => {
!isCopied
? (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/Boleto.res
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let make = (~paymentType: CardThemeType.mode, ~list: PaymentMethodsRecord.list)

let socialSecurityNumberRef = React.useRef(Nullable.null)

let (complete, empty) = React.useMemo1(() => {
let (complete, empty) = React.useMemo(() => {
(
socialSecurityNumber->cleanSocialSecurityNumber->String.length == 11,
socialSecurityNumber->String.length == 0,
Expand Down
6 changes: 3 additions & 3 deletions src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let make = (
maxCardLength,
) = cardProps

let cardBrand = React.useMemo1(() => {
let cardBrand = React.useMemo(() => {
cardNumber->CardUtils.getCardBrand
}, [cardNumber])

Expand Down Expand Up @@ -88,7 +88,7 @@ let make = (
None
}, (empty, complete))

let (savedMethods, isGuestCustomer) = React.useMemo1(() => {
let (savedMethods, isGuestCustomer) = React.useMemo(() => {
switch customerPaymentMethods {
| LoadedSavedCards(savedMethods, isGuest) => (savedMethods, isGuest)
| NoResult(isGuest) => ([], isGuest)
Expand All @@ -103,7 +103,7 @@ let make = (
~isCvcValidValue,
)

let isCustomerAcceptanceRequired = React.useMemo2(() => {
let isCustomerAcceptanceRequired = React.useMemo(() => {
if displaySavedPaymentMethodsCheckbox {
isSaveCardsChecked || list.payment_type === SETUP_MANDATE
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/Payments/GPay.res
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ let make = (
let areRequiredFieldsValid = Recoil.useRecoilValueFromAtom(RecoilAtoms.areRequiredFieldsValid)
let areRequiredFieldsEmpty = Recoil.useRecoilValueFromAtom(RecoilAtoms.areRequiredFieldsEmpty)
let status = CommonHooks.useScript("https://pay.google.com/gp/p/js/pay.js")
let isGooglePaySDKFlow = React.useMemo1(() => {
let isGooglePaySDKFlow = React.useMemo(() => {
sessionObj->Option.isSome
}, [sessionObj])
let isGooglePayThirdPartyFlow = React.useMemo1(() => {
let isGooglePayThirdPartyFlow = React.useMemo(() => {
thirdPartySessionObj->Option.isSome
}, [sessionObj])

Expand All @@ -50,15 +50,15 @@ let make = (
| None => PaymentMethodsRecord.RedirectToURL
}

let isInvokeSDKFlow = React.useMemo1(() => {
let isInvokeSDKFlow = React.useMemo(() => {
(isGooglePaySDKFlow || isGooglePayThirdPartyFlow) &&
paymentExperience == PaymentMethodsRecord.InvokeSDK
}, [sessionObj])
let (connectors, _) = isInvokeSDKFlow
? list->PaymentUtils.getConnectors(Wallets(Gpay(SDK)))
: list->PaymentUtils.getConnectors(Wallets(Gpay(Redirect)))

let isDelayedSessionToken = React.useMemo1(() => {
let isDelayedSessionToken = React.useMemo(() => {
thirdPartySessionObj
->Option.flatMap(JSON.Decode.object)
->Option.flatMap(x => x->Dict.get("delayed_session_token"))
Expand Down
4 changes: 2 additions & 2 deletions src/Payments/PaymentRequestButtonElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ let make = (~sessions, ~walletOptions, ~list: PaymentMethodsRecord.list) => {
open SessionsType
let dict = sessions->Utils.getDictFromJson

let sessionObj = React.useMemo1(() => itemToObjMapper(dict, Others), [dict])
let paypalToken = React.useMemo1(
let sessionObj = React.useMemo(() => itemToObjMapper(dict, Others), [dict])
let paypalToken = React.useMemo(
() => getPaymentSessionObj(sessionObj.sessionsToken, Paypal),
[sessionObj],
)
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/QRCodeDisplay.res
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ let make = () => {
->ignore
}

let expiryString = React.useMemo1(() => {
let expiryString = React.useMemo(() => {
let minutes = (expiryTime /. 60000.0)->Belt.Float.toInt->Belt.Int.toString
let seconds =
mod(expiryTime->Belt.Float.toInt, 60000)->Belt.Int.toString->String.slice(~start=0, ~end=2)
Expand Down
4 changes: 2 additions & 2 deletions src/SingleLineCardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ let make = (
let isExpiryValidValue = getBoolOptionVal(isExpiryValid)
let isCVCValidValue = getBoolOptionVal(isCVCValid)
let isZipValidValue = getBoolOptionVal(isZipValid)
let (showPincode, pincodeClass) = React.useMemo1(
let (showPincode, pincodeClass) = React.useMemo(
() => displayPincode ? ("block", "animate-slideLeft") : ("none", "animate-slideRight "),
[displayPincode],
)
let checkLengthIsZero = item => String.length(item) == 0
let checkValueIsValid = item => item == "valid"
let checkValueIsInvalid = item => item == "invalid"

let (cardEmpty, cardComplete, cardInvalid, cardFocused) = React.useMemo4(() => {
let (cardEmpty, cardComplete, cardInvalid, cardFocused) = React.useMemo(() => {
let isCardDetailsEmpty = Array.every(
[cardNumber, cardExpiry, cvcNumber, zipCode],
checkLengthIsZero,
Expand Down
2 changes: 1 addition & 1 deletion src/TabCard.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let make = (~paymentOption: PaymentMethodsRecord.paymentFieldsInfo, ~isActive: b
let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom)
let {readOnly, customMethodNames} = Recoil.useRecoilValueFromAtom(optionAtom)
let setSelectedOption = Recoil.useSetRecoilState(selectedOptionAtom)
let (tabClass, tabLabelClass, tabIconClass) = React.useMemo1(
let (tabClass, tabLabelClass, tabIconClass) = React.useMemo(
() => isActive ? ("Tab--selected", "TabLabel--selected", "TabIcon--selected") : ("", "", ""),
[isActive],
)
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/DynamicFieldsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ let useSubmitCallback = () => {
}

let usePaymentMethodTypeFromList = (~list, ~paymentMethod, ~paymentMethodType) => {
React.useMemo3(() => {
React.useMemo(() => {
PaymentMethodsRecord.getPaymentMethodTypeFromList(
~list,
~paymentMethod,
Expand Down

0 comments on commit 9385f31

Please sign in to comment.