From 393ec1fc175f74c9675e31f1672797b76ee84cbb Mon Sep 17 00:00:00 2001 From: "darwin.apolinario" Date: Wed, 1 Nov 2023 20:20:25 +0800 Subject: [PATCH] fix(marketingmain): footer sidebar `dynamic` --- src/layouts/Main/MarketingMain.js | 4 +++- .../Main/components/Footer/FooterDynamic.js | 16 ++++++++++++++++ src/pages/_app.js | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/layouts/Main/components/Footer/FooterDynamic.js diff --git a/src/layouts/Main/MarketingMain.js b/src/layouts/Main/MarketingMain.js index ac49a75e9..a7c00b14d 100644 --- a/src/layouts/Main/MarketingMain.js +++ b/src/layouts/Main/MarketingMain.js @@ -15,11 +15,13 @@ import useIsLoggedIn from 'components/hooks/useIsLoggedIn'; import { setCookie } from 'cookies-next'; import { useZestyStore } from 'store'; -import { Topbar, Sidebar, Footer } from './components'; +import { Topbar } from './components'; import dynamic from 'next/dynamic'; import revampTheme from 'theme/revampTheme'; +const Footer = dynamic(() => import('./components/Footer/FooterDynamic')); +const Sidebar = dynamic(() => import('./components').then((e) => e.Sidebar)); const TopNav = dynamic(() => import('components/globals/TopNav')); const SiteBanner = dynamic( () => import('components/marketing/SiteBanner/SiteBanner'), diff --git a/src/layouts/Main/components/Footer/FooterDynamic.js b/src/layouts/Main/components/Footer/FooterDynamic.js new file mode 100644 index 000000000..e54fdb6f4 --- /dev/null +++ b/src/layouts/Main/components/Footer/FooterDynamic.js @@ -0,0 +1,16 @@ +import dynamic from 'next/dynamic'; +import { useInView } from 'react-intersection-observer'; + +const Child = dynamic(() => import('./Footer'), { + loading: () => <>, +}); + +const Index = (props) => { + const { ref, inView } = useInView({ + triggerOnce: true, + threshold: 0, + }); + return
{inView && }
; +}; + +export default Index; diff --git a/src/pages/_app.js b/src/pages/_app.js index 65c7f9790..b5e8eb8e0 100644 --- a/src/pages/_app.js +++ b/src/pages/_app.js @@ -19,7 +19,6 @@ import '/public/styles/docs.css'; if (process.env.NODE_ENV === 'production') { console.log = () => {}; - console.error = () => {}; console.debug = () => {}; }