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

295
Views
React Router V5 - link component is not switching routes (but an anchor link works)

I've got a create react app with react router v5 and the following setup:

import React, { useState } from "react";
import "./App.css";
import { BrowserRouter, Route, Switch } from "react-router-dom";
import EmailRep from "./components/EmailRep";
import WebAuthN from "./components/WebAuthN";

function App() {
  return (
    <div className="App">
      <BrowserRouter>
        <Switch>
          <Route exact path="/">
            <EmailRep />
          </Route>
          <Route path="/webauthn">
            <WebAuthN />
          </Route>
        </Switch>
      </BrowserRouter>
    </div>
  );
}

export default App;

In my EmailRep component, if I attempt to link to the WebAuthN route, it does nothing

import React from "react";
import { Link } from "react-router-dom";

export default function EmailRep() {
  return <Link to="/webauthn">WebAuthN</Link>;
}

But this works:

import React from "react";
import { Link } from "react-router-dom";

export default function EmailRep() {
  return <a href="/webauthn">WebAuthN</a>`;
}

What am I missing?

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

0

I can't tell if this is your case because you didn't share those components code but maybe you forgot to import the Link module from react-router-dom,

Try inserting this snippet at the top of your EmailRep and WebAuthN modules:
import { Link } from 'react-router-dom'

Hope this helps!

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!