Skip to content

Commit

Permalink
Adding lazy loading to the portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkyebrahim2514 committed Feb 5, 2024
1 parent 77660ff commit a58a80d
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions react-frontend/src/Portfolio.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { useThemeContext } from './contexts/ThemeContext';
import About from './containers/About';
import Navbar from './components/Navbar';
import Skills from './containers/Skills';
import Education from './containers/Education';
import Experience from './containers/Experience';
import Projects from './containers/Projects';
import Contacts from './containers/Contacts';
import { useNavigationControllerContext } from './contexts/NavigationControllerContext';
import { Suspense, lazy } from 'react';
import Loader from './components/Loader';

const About = lazy(() => import('./containers/About'));
const Skills = lazy(() => import('./containers/Skills'));
const Education = lazy(() => import('./containers/Education'));
const Experience = lazy(() => import('./containers/Experience'));
const Projects = lazy(() => import('./containers/Projects'));

export default function Portfolio() {
const { theme } = useThemeContext();
Expand All @@ -25,12 +28,14 @@ export default function Portfolio() {
padding: "0 1rem",
}}>
<Navbar />
{links.about && <About />}
{links.skills && <Skills />}
{links.education && <Education />}
{links.experience && <Experience />}
{links.projects && <Projects />}
{links.contacts && <Contacts />}
<Suspense fallback={<Loader />}>
{links.about && <About />}
{links.skills && <Skills />}
{links.education && <Education />}
{links.experience && <Experience />}
{links.projects && <Projects />}
{links.contacts && <Contacts />}
</Suspense>
</div>
</div>
)
Expand Down

0 comments on commit a58a80d

Please sign in to comment.