Open Supratip1 opened 1 year ago
Working on link code depends on two factors. First navLink array in src/components/constant check id there and Second SectionWrapper export of every src/components means in export default of components mean code below
export default SectionWrapper(About, "about")
check the spelling of the string inside " " and the string of the nav link array id
export const navLinks = [ { id: "about", title: "About", }, { id: "work", title: "My Education", }, { id: "contact", title: "Contact", }, { id: "resume", title: "resume", }, ];
The About, Work and Contact is not scrolling to the respective sections on being clicked. They are becoming active and changing to white color but not scrolling to their respective sections. Here Is my code for Navbar.jsx:
import React, { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { styles } from "../styles"; import { navLinks } from "../constants"; import { logo, menu, close } from "../assets";
const Navbar = () => { const [active, setActive] = useState(""); const [toggle, setToggle] = useState(false); const [scrolled, setScrolled] = useState(false);
useEffect(() => { const handleScroll = () => { const scrollTop = window.scrollY; if (scrollTop > 100) { setScrolled(true); } else { setScrolled(false); } };
}, []);
return (
); };
export default Navbar;
Any help will be appreciated