Trouble with React-router-dom

Hello everyone, I am having an issue with react router and I can’t figure out why.
I followed the example of my previous project, but no matter how I try to navigate away the component will always stay the same.

<div className="willchange">
        <Router>
          <Switch>
            <Route path="/" component={Homepage} />
            <Route path="/Projects" component={Projects} />

            <Route path="/Skills" component={Skills} />
          </Switch>
        </Router>
      </div>

My full project is here :


Thanks in advance for your help.

Hello there.

Switch matches the first path. Ie. / will always match. So, you should place it last.

Hope this helps

1 Like
  1. In menu.js remove the Router component.

  2. In App.js move the Router component up so it is the parent of all other elements/components.

  3. Add exact to the “/” Route component.

1 Like