Ian
Ian

Reputation: 39

React Router problem with "Link", Error: Invariant failed: You should not use <Link> outside a <Router>

My issue is when I try to use "Link" in my Nav.js, I get an Error of

enter image description here

Here is my App.js

Here is my Nav.js

Here is my Orders.js

[Here is my Products.js4

Upvotes: 0

Views: 296

Answers (2)

lala
lala

Reputation: 1439

The first error that may occurs will come from your Home function component:-

  • in App.js:- edit your const Home to this (it should be wrap in return):-
const Home = () => {
  return (
    <div>
      <h1>Homepage</h1>
    </div>
  )
}

Other than that everything will works just fine tho. Anyhow, you can see it here on this sandbox to compare it with your current code.

Upvotes: 1

krimo
krimo

Reputation: 684

use <BrowserRouter> in Nav component

Upvotes: 1

Related Questions