From ade0a91d6c50322dce1e0b514c029fc58451a228 Mon Sep 17 00:00:00 2001 From: "joao.congio" Date: Thu, 11 Apr 2024 14:05:43 -0300 Subject: [PATCH 1/2] feat(imgs): removing lazy loading from eager images in the first fold --- react/components/LazyImages.tsx | 4 +++- react/core/main.tsx | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/react/components/LazyImages.tsx b/react/components/LazyImages.tsx index 10f40fef9..88c885180 100644 --- a/react/components/LazyImages.tsx +++ b/react/components/LazyImages.tsx @@ -43,15 +43,17 @@ const useLazyImagesContext = () => { interface MaybeLazyImageProps { createElement: typeof React.createElement imageProps: Record + lazyType: string } const MaybeLazyImage: FC = ({ createElement = React.createElement, imageProps, + lazyType, }) => { const { lazyLoad, method } = useLazyImagesContext() - if (lazyLoad) { + if (lazyLoad && lazyType !== 'eager') { let newImageProps = imageProps switch (method) { diff --git a/react/core/main.tsx b/react/core/main.tsx index 990849033..cff8c7e35 100644 --- a/react/core/main.tsx +++ b/react/core/main.tsx @@ -347,6 +347,7 @@ function start() { { createElement: ReactCreateElement, imageProps: props, + lazyType: props.loading, }, ]) } From 07f982335ef9ae2840cc57e3302687d0bc38e117 Mon Sep 17 00:00:00 2001 From: joaocore Date: Tue, 21 May 2024 17:37:21 -0300 Subject: [PATCH 2/2] fix: changed const name --- react/components/LazyImages.tsx | 6 +++--- react/core/main.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/react/components/LazyImages.tsx b/react/components/LazyImages.tsx index 88c885180..fab8cc68f 100644 --- a/react/components/LazyImages.tsx +++ b/react/components/LazyImages.tsx @@ -43,17 +43,17 @@ const useLazyImagesContext = () => { interface MaybeLazyImageProps { createElement: typeof React.createElement imageProps: Record - lazyType: string + loadingType: string } const MaybeLazyImage: FC = ({ createElement = React.createElement, imageProps, - lazyType, + loadingType, }) => { const { lazyLoad, method } = useLazyImagesContext() - if (lazyLoad && lazyType !== 'eager') { + if (lazyLoad && loadingType !== 'eager') { let newImageProps = imageProps switch (method) { diff --git a/react/core/main.tsx b/react/core/main.tsx index cff8c7e35..a629e89d2 100644 --- a/react/core/main.tsx +++ b/react/core/main.tsx @@ -347,7 +347,7 @@ function start() { { createElement: ReactCreateElement, imageProps: props, - lazyType: props.loading, + loadingType: props.loading, }, ]) }