Skip to content

Commit

Permalink
increase performance
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadrezaAmani committed Apr 4, 2024
1 parent 252791a commit df990b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "yarn run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
Expand Down
30 changes: 23 additions & 7 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React, { useMemo } from "react";

import Header from "./../components/header";
import Footer from "./../components/footer";
import { veryFullArgs } from "./../configs/types";
Expand All @@ -9,18 +11,32 @@ export function Layout({
toggleTheme,
children,
}: veryFullArgs) {
// Memoize the Header component
const memoizedHeader = useMemo(
() => (
<Header
lang={lang}
toggleLang={toggleLang}
theme={theme}
toggleTheme={toggleTheme}
/>
),
[lang, toggleLang, theme, toggleTheme]
);

// Memoize the Footer component
const memoizedFooter = useMemo(
() => <Footer lang={lang} theme={theme} slug="/" />,
[lang, theme]
);

return (
<div className="flex flex-col justify-between h-screen">
<div className="flex flex-col w-full">
<Header
lang={lang}
toggleLang={toggleLang}
theme={theme}
toggleTheme={toggleTheme}
/>
{memoizedHeader}
{children}
</div>
<Footer lang={lang} theme={theme} slug="/" />
{memoizedFooter}
</div>
);
}

0 comments on commit df990b3

Please sign in to comment.