Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is react not letting me use a router dom Link inside of an html list item?

I have the following Link within a html list item and I am getting an error.

<li className="nav-item">
  <Link to={'/cart'}>
    <i
      className="fa fa-shopping-bag"
      style={{fontSize: "22px"}}></i>
  </Link>
</li>

The error:

index.tsx:19 Uncaught Error: useHref() may be used only in the context of a <Router> component.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Because somewhere, farther up on the tree you did not wrap your components in a router component, which is required to make react router work.

See: https://v5.reactrouter.com/web/guides/quick-start/1st-example-basic-routing

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading