Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
How to add smooth srcolling and scroll feature in react without react-scroll package

I want to add smooth scrolling feature in my react website. I have a header component that holds the navigation bar which has three links concerned Home, Service, About. The Service and the About is linked to their respective components i.e. Service.js and About.js. Now I have a made a Home component that holds the three components inside it ie, Hero, Service, About, hence, in the home page these components are stacked below eachother .I want that whenever the user clicks the Links in the header it should scroll down to that sepcific component rather then navigating to the component and rendering it seperately.

I tried using react-scroll package from a tutorial and it worked as expected but then I realised that the links don't work anymore as real links. So a user if suppose in the login page he doesn't get redirected to the home page if he clicks the home link or the service link or the about. I am new to react and have no idea how to do it. Please suggest me a way to make smooth scrolling.

Below are the codes.

Header.js

function Header() {
  return (
    <Nav>
      <Link to="/">
        <Logo src="/images/logo_name_header.svg" />
      </Link>

      <NavMenu>
        <ul>
          <li>
            <Link to="/">
              <span>Home</span>
            </Link>
          </li>
          <li>
            <Link to="/service">
              <span>Service</span>
            </Link>
          </li>

          <li>
            <Link to="/about-us">
              <span>About Us</span>
            </Link>
          </li>
          <li>
            <Link to="/contact">
              <span>Contact Us</span>
            </Link>
          </li>

          <li>
            <Link to="/register">
              <div className="cta-register">Register</div>
            </Link>
          </li>

          <li>
            <Link to="/login">
              <span>Login</span>
            </Link>
          </li>
        </ul>
      </NavMenu>
    </Nav>
  );
}

export default Header;

Home.js

function Home() {
  return (
    <Container>
      <Hero />
      <Service />
      <About />
    </Container>
  );
}

export default Home;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simple CSS scroll-behavior: smooth doesn’t work for you? docs

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!