import React, { useState, useEffect, useContext } from "react"; import { Transition } from "@headlessui/react"; import { Fade } from "react-reveal"; import { Link, useNavigate } from "react-router-dom"; import { getAuth, signOut } from "firebase/auth"; import { AuthContext } from "../../Context/UserContext"; function Navbar(props) { const { User } = useContext(AuthContext); const [profilePic, setProfilePic] = useState(""); const navigate = useNavigate(); useEffect(() => { if (User != null) { setProfilePic(User.photoURL); } window.addEventListener("scroll", transitionNavBar); console.log("Navbar", User); return () => { window.removeEventListener("scroll", transitionNavBar); }; }, []); const [isOpen, setIsOpen] = useState(false); const [show, handleShow] = useState(false); const transitionNavBar = () => { if (window.scrollY > 80) { handleShow(true); } else { handleShow(false); } }; const NavBlack = () => { handleShow(true); }; const NavTransparent = () => { handleShow(false); }; const SignOut = () => { const auth = getAuth(); signOut(auth) .then(() => { navigate("/"); }) .catch((error) => { alert(error.message); }); }; return (
); } export default Navbar;