From c1ae173799335e2aebb37ef8a1c29145ea70f9d1 Mon Sep 17 00:00:00 2001 From: Anthony Dumas Date: Mon, 18 Jul 2022 23:57:53 +0200 Subject: [PATCH] Lazy loading des composants --- src/App.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/App.js b/src/App.js index 762ebd9..84941c9 100644 --- a/src/App.js +++ b/src/App.js @@ -1,20 +1,31 @@ import './App.css'; import './_sass/index.scss'; -import MenuComponent from './components/MenuComponent/index'; -import MainCard from './components/MainCard/MainCard'; -import ProjectsCard from './components/ProjectsCard'; -import ContactCard from './components/ContactCard'; -import FooterCard from './components/FooterCard'; +import { lazy, Suspense } from 'react'; + + +const MenuComponent = lazy(() => import('./components/MenuComponent/index')); +const MainCard = lazy(() => import('./components/MainCard/MainCard')); +const ProjectsCard = lazy(() => import('./components/ProjectsCard')); +const ContactCard = lazy(() => import('./components/ContactCard')); +const FooterCard = lazy(() => import('./components/FooterCard')); + +const renderLoader = () =>

Loading

; function App() { return (
- - - - - + + + + + + + + + + +
); }