I am trying to build a portfolio with multiple pages. The very first page is a loader screen with some text. Right after the loader screen finishes, the landing page shows up.
The issue is, every time the user visits a page within the portfolio and comes back to the / landing page, the loader screen reappears. I only want it to appear when the user visits the portfolio for the very first time.
Here is the code -
"use client";
import { useState, useRef } from "react";
import Hero from "./Hero";
import Loader from "./Loader";
import Writer from "./Writer";
import Years from "./Years";
import HorizontalBooks from "./HorizontalBooks";
import LawText from "./LawText";
import Gallery from "./Gallery";
import Footer from "./Footer";
export default function Page() {
const loaderComplete = useRef(false);
const handleComplete = () => {
loaderComplete.current = true;
};
return (
<main>
{!loaderComplete.current && <Loader onComplete={handleComplete} />}
<Hero />
<Writer />
<div className="hidden md:block">
<HorizontalBooks />
</div>
<Years />
<LawText />
<Gallery />
<Footer />
</main>
);
}
Here is a screen record of the issue - https://streamable.com/fcyzg9
Stackbltiz - https://stackblitz.com/edit/github-sq9mef9f?file=app%2Fpage.tsx