Skip to content

Fix 1: Lazy load page sections #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
// @ts-nocheck
import React from 'react';
import Menu from './components/Menu';
import React, { Suspense, lazy } from 'react';
import Hero from './components/Hero';
import Sidebar from './components/Sidebar';
import Products from './components/Products';
import BoringContent from './components/BoringContent';
import Footer from './components/Footer';
import Menu from './components/Menu';
import './App.css';

const Sidebar = lazy(() => import('./components/Sidebar'));
const Products = lazy(() => import('./components/Products'));
const BoringContent = lazy(() => import('./components/BoringContent'));
const Footer = lazy(() => import('./components/Footer'));

const App = () => (
<>
<Menu />
<Sidebar />
<Suspense fallback={<div />}>
<Sidebar />
</Suspense>
<div id="main">
<Hero />
<main>
<Products />
<BoringContent />
<Suspense fallback={<div />}>
<Products />
</Suspense>
<Suspense fallback={<div />}>
<BoringContent />
</Suspense>
</main>
</div>
<Footer />
<Suspense fallback={<div />}>
<Footer />
</Suspense>
</>
);

Expand Down