diff --git a/src/App.jsx b/src/App.jsx index 1c3ce88..7b30dda 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { BrowserRouter } from "react-router-dom"; import { About, diff --git a/src/components/Banner.jsx b/src/components/Banner.jsx index a880bee..766b114 100644 --- a/src/components/Banner.jsx +++ b/src/components/Banner.jsx @@ -3,8 +3,14 @@ import { Link } from "react-router-dom"; import { close, bulb } from "../assets"; +const BANNER_KEY = "hide-banner"; + const Banner = ({ hide, setHide }) => { useEffect(() => { + const hideBanner = localStorage.getItem(BANNER_KEY); + + if (hideBanner) return; + const bannerTimer = setTimeout(() => { setHide(false); }, 5000); @@ -12,6 +18,11 @@ const Banner = ({ hide, setHide }) => { return () => clearTimeout(bannerTimer); }, []); + const handleBannerClose = () => { + setHide(true); + localStorage.setItem(BANNER_KEY, true); + }; + return (