Skip to content

Commit

Permalink
Fix dynamically import Modal component (vercel#539)
Browse files Browse the repository at this point in the history
* fix: dynamically import Modal component

fixes error "document is not defined" if the user decides to display a modal at the beginning (for ads, promotions, etc...)

* fix: remove spread operator

* remove top level modal import

* fix import path for Modal

Co-authored-by: Gonzalo Pozzo <[email protected]>
  • Loading branch information
luisorbaiceta and goncy authored Nov 24, 2021
1 parent 683d309 commit c878786
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/common/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Category } from '@commerce/types/site'
import ShippingView from '@components/checkout/ShippingView'
import CartSidebarView from '@components/cart/CartSidebarView'
import { useAcceptCookies } from '@lib/hooks/useAcceptCookies'
import { Sidebar, Button, Modal, LoadingDots } from '@components/ui'
import { Sidebar, Button, LoadingDots } from '@components/ui'
import PaymentMethodView from '@components/checkout/PaymentMethodView'
import CheckoutSidebarView from '@components/checkout/CheckoutSidebarView'

Expand Down Expand Up @@ -42,6 +42,11 @@ const FeatureBar = dynamic(
dynamicProps
)

const Modal = dynamic(
() => import('@components/ui/Modal'),
Object.assign(dynamicProps, {ssr: false})
)

interface Props {
pageProps: {
pages?: Page[]
Expand Down

0 comments on commit c878786

Please sign in to comment.