From 1953438b29ec0081f0dc12fe73a06cd10225a8e8 Mon Sep 17 00:00:00 2001 From: Eduardo Formiga Date: Fri, 20 Dec 2024 17:37:11 -0300 Subject: [PATCH] fix: removes `useUI()` dependents sections from `LazyLoadingSection` (#2602) ## What's the purpose of this pull request? This removes the logic that dynamically loads the sections that depend on the `useUI()` hook: `CartSidebar` and `RegionModal`. We decided to try to load them at another moment (//TODO: create a task for it) instead of on click. ## How to test it? Try to load the respective sections `CartSidebar` and `RegionModal` using the [preview link](https://sfj-2714681--starter.preview.vtex.app/). You can see that both sections are being loaded in the initial loading now. Instead of loading after clicking on the respective buttons that trigger the sections. ### Starters Deploy Preview - https://github.com/vtex-sites/starter.store/pull/639 - preview https://sfj-2714681--starter.preview.vtex.app/ --- packages/core/src/components/cms/RenderSections.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/core/src/components/cms/RenderSections.tsx b/packages/core/src/components/cms/RenderSections.tsx index 311729f244..85866139d6 100644 --- a/packages/core/src/components/cms/RenderSections.tsx +++ b/packages/core/src/components/cms/RenderSections.tsx @@ -12,8 +12,6 @@ import SectionBoundary from './SectionBoundary' import ViewportObserver from './ViewportObserver' import COMPONENTS from './global/Components' -import { useUI } from '@faststore/ui' - interface Props { components?: Record> globalSections?: Array<{ name: string; data: any }> @@ -55,15 +53,10 @@ export const LazyLoadingSection = ({ sectionName: string children: ReactNode }) => { - const { cart: displayCart, modal: displayModal } = useUI() - if (SECTIONS_OUT_OF_VIEWPORT.includes(sectionName)) { - const shouldLoad = - (sectionName === 'CartSidebar' && displayCart) || - (sectionName === 'RegionModal' && displayModal) - - return shouldLoad ? <>{children} : null + return <>{children} } + return ( {children} )