DEV Community

lughjw
lughjw

Posted on

1

A React Router Bug Tip

I started learning React recently and wanted to focus on the Router component. Here I'll post a few things I learn as I go through it. I'll update this as I come across new tidibts.

  • If you're clicking on a Link and it's not taking you anywhere but it is changing your url, then check to make sure that the link is within your Router component (Be that a BrowserRouter, HashRouter, MemoryRouter, etc). It can be nested within children which are in the Router, but needs to be within the Router. An example:
<Router>
    <NavBar />
    <Route exact path="/" render={(props) => <MyComponent {...props} />} />
    {/* Other Routes here */}
</Router>

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay