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

751
Views
bootstrap nav link is not working in reactjs

I'm new here also newbie on ReactJS.

Here I created a navbar using bootstrap navbar component in Reactjs.

<Navbar collapseOnSelect expand="lg">
  <Container>
    <Navbar.Brand to={"/"}>Rental</Navbar.Brand>
    <Navbar.Toggle aria-controls="responsive-navbar-nav" />
    <Navbar.Collapse id="responsive-navbar-nav">

    <Nav>
      <Nav.Link to="/" >
         <FontAwesomeIcon 
          icon={faHome} 
       /> Home
     </Nav.Link>
     <Nav.Link to="/login" >
        <FontAwesomeIcon 
        icon={faUser} 
        /> Login/ Registration
     </Nav.Link>
  </Nav>
  </Navbar.Collapse>
 </Container>
</Navbar>

When I go Browser and Check It shows like this:

<a to="/" role="button" class="nav-link" tabindex="0">Home</a>

and the link won't working.

How to fix it?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It looks like you're rendering react-bootstrap's Nav.Link instead of react-router's Link component, so the router is not picking up your route changes.

So importing Link from react router and using it should fix the issue.

import { Link } from 'react-router-dom';

<Nav.Link as={Link} to="/" >
   <FontAwesomeIcon 
      icon={faHome} 
    /> Home
</Nav.Link>

about 4 years ago · Juan Pablo Isaza Report

0

Wrap your code in a Router, make sure that you're doing that inside App or in ReactDOM.render:

import { BrowserRouter } from 'react-router-dom';

ReactDOM.render(
  <BrowserRouter>
    <App />
  </BrowserRouter>, 
  rootElement
  );

You're rendering react-bootstrap's Nav.Link instead of react-router's Link component, so the router is not picking up your route changes.

react-bootstrap provides a render prop in most of its components to specify which component or element we want to render if we don't want the default.

Try to make these changes!

import { Switch, Route, Link } from 'react-router-dom';
<Navbar.Brand as={Link} to="/" >Rental</Navbar.Brand>
<Nav.Link as={Link} to="/" >
    <FontAwesomeIcon icon={faHome}/>
        Home
</Nav.Link>
<Nav.Link as={Link} to="/login" >
    <FontAwesomeIcon icon={faUser}/> 
        Login/ Registration
</Nav.Link>
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!