Changeset 3ebe47c for frontend/src/pages/LandingPage/components/Hero.jsx
- Timestamp:
- 02/09/26 21:36:40 (5 months ago)
- Branches:
- master
- Children:
- 8615885
- Parents:
- 140d098
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/pages/LandingPage/components/Hero.jsx
r140d098 r3ebe47c 1 import React from "react"; 1 import React, { useEffect, useState } from "react"; 2 import { Link } from "react-router-dom"; 2 3 3 4 const Hero = () => { 5 const [isAuthed, setIsAuthed] = useState(() => 6 Boolean(localStorage.getItem("authToken")), 7 ); 8 9 useEffect(() => { 10 const onStorage = (e) => { 11 if (e.key === "authToken") { 12 setIsAuthed(Boolean(e.newValue)); 13 } 14 }; 15 window.addEventListener("storage", onStorage); 16 return () => window.removeEventListener("storage", onStorage); 17 }, []); 18 4 19 return ( 5 20 <div … … 21 36 consistently, and see your progress in one place. 22 37 </p> 23 <button className="btn btn-primary">Get started</button> 38 <Link 39 className="btn btn-primary" 40 to={isAuthed ? "/dashboard" : "/register"} 41 > 42 {isAuthed ? "Go to dashboard" : "Get started"} 43 </Link> 24 44 </div> 25 45 </div>
Note:
See TracChangeset
for help on using the changeset viewer.
