From f6fc648b285a6151885d970578bfaf68418c234c Mon Sep 17 00:00:00 2001 From: GabrielBarros Date: Thu, 18 Aug 2022 16:32:59 -0300 Subject: [PATCH] UseMemo and React.FC Type fix --- react/AffiliateProfileValidator.tsx | 17 +++++++++++------ react/AffiliateValidator.tsx | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/react/AffiliateProfileValidator.tsx b/react/AffiliateProfileValidator.tsx index 03dc2f0..3cb7bea 100644 --- a/react/AffiliateProfileValidator.tsx +++ b/react/AffiliateProfileValidator.tsx @@ -7,8 +7,8 @@ import useAffiliate from './context/useAffiliate' import { getSlugStoreFront } from './utils/shared' type Props = { - Invalid: React.ComponentType - Valid: React.ComponentType + Invalid: React.FC + Valid: React.FC } const AffiliateProfileValidator: FC = ({ Valid, Invalid }) => { @@ -19,11 +19,16 @@ const AffiliateProfileValidator: FC = ({ Valid, Invalid }) => { const { orderForm } = useOrderForm() - const loading = - orderForm?.clientProfileData === undefined || - affiliate.affiliateOrdersLoading + const loading = useMemo(() => { + return ( + orderForm?.clientProfileData === undefined || + affiliate.affiliateOrdersLoading + ) + }, [orderForm, affiliate]) - const isValid = affiliate?.affiliate?.slug === slug + const isValid = useMemo(() => { + return affiliate?.affiliate?.slug === slug + }, [affiliate, slug]) if (loading) { return ( diff --git a/react/AffiliateValidator.tsx b/react/AffiliateValidator.tsx index 6bb73b1..9e8ac12 100644 --- a/react/AffiliateValidator.tsx +++ b/react/AffiliateValidator.tsx @@ -14,8 +14,8 @@ export type IsAffiliateValidQueryResult = { } type Props = { - Invalid: React.ComponentType - Valid: React.ComponentType + Invalid: React.FC + Valid: React.FC } const AffiliateValidator: FC = ({ Invalid, Valid }) => {