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

150
Views
Want to build Header component from Bootstrap template to React but my browser throwing below errors

Want to build Header component from Bootstrap template but my browser is throwing the following error:

Uncaught Error: Invariant failed: You should not use <NavLink> outside a <Router>

The above error occurred in the <Router.Consumer> component

I imported:

import React from 'react';
import { NavLink } from 'react-router-dom';

in my Header.js and converted my all <a> in <NavLink to='/Shop' >Shop</NavLink>

and my App.js is like this:

import Header from './components/Header';
import Footer from './components/Footer';
import Home from './container/Home';
import Shop from './container/Shop';
import {Switch} from 'react-router-dom';
import {Route} from 'react-router-dom';


function App() {
  return (
    <>
      <Header />
        <Switch>
          <Route path='/' exact component={Home} />
          <Route path='/shop' exact component={Shop} />
        </Switch>
      <Footer />
    </>
  );
}

export default App;

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

0

In your App.js, Add Router component

Like this

import Header from './components/Header';
import Footer from './components/Footer';
import Home from './container/Home';
import Shop from './container/Shop';
import {Switch} from 'react-router-dom';
import {Route} from 'react-router-dom';
import {BrowserRouter as Router} from 'react-router-dom';


function App() {
  return (
    <>
        <Router>
           <Header />
            <Switch>
              <Route path='/' exact component={Home} />
              <Route path='/shop' exact component={Shop} />
            </Switch>
           <Footer />
        </Router>
    </>
  );
}

export default App;
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!