From 115cf12529c6aaed10bd24e66e03b8614cb7504f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Sat, 7 Nov 2020 19:15:54 -0300 Subject: [PATCH 1/2] Removing useDialog, cause rerender --- .../cart/CartSidebarView/CartSidebarView.tsx | 2 +- components/common/Layout/Layout.tsx | 8 +- components/ui/Modal/Modal.tsx | 27 +---- components/ui/Sidebar/Sidebar.tsx | 100 +++++++++--------- package.json | 26 +++-- pages/index.tsx | 2 +- yarn.lock | 39 ++++++- 7 files changed, 112 insertions(+), 92 deletions(-) diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx index 0ad7b95f1..b35fdb18b 100644 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ b/components/cart/CartSidebarView/CartSidebarView.tsx @@ -10,6 +10,7 @@ import CartItem from '../CartItem' import s from './CartSidebarView.module.css' const CartSidebarView: FC = () => { + const { closeSidebar } = useUI() const { data, isEmpty } = useCart() const { price: subTotal } = usePrice( data && { @@ -23,7 +24,6 @@ const CartSidebarView: FC = () => { currencyCode: data.currency.code, } ) - const { closeSidebar } = useUI() const handleClose = () => closeSidebar() const items = data?.line_items.physical_items ?? [] diff --git a/components/common/Layout/Layout.tsx b/components/common/Layout/Layout.tsx index d53f0a740..f76a75561 100644 --- a/components/common/Layout/Layout.tsx +++ b/components/common/Layout/Layout.tsx @@ -10,6 +10,7 @@ import { useAcceptCookies } from '@lib/hooks/useAcceptCookies' import { CommerceProvider } from '@bigcommerce/storefront-data-hooks' import { Sidebar, Button, Modal, LoadingDots } from '@components/ui' import type { Page } from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' +import { CartSidebarView } from '@components/cart' const Loading = () => (
@@ -20,9 +21,7 @@ const Loading = () => ( const dynamicProps = { loading: () => , } -const CartSidebarView = dynamic( - () => import('@components/cart/CartSidebarView') -) + const LoginView = dynamic( () => import('@components/auth/LoginView'), dynamicProps @@ -67,14 +66,17 @@ const Layout: FC = ({ children, pageProps }) => {
{children}