Skip to content
Advertisement

React multiple pages using react-router-dom

I m trying to make multiple react pages but react doesn’t show any of the new pages . I think my code is correct , I am using npm install react-router-dom@6 and this is my code : Index.js

JavaScript

in the Navbar.jsx :

JavaScript

and for example Pricing.js :

JavaScript

Any idea how to fix this ? where I have missed it exactly ?

Advertisement

Answer

First you are missing / on some path. Second, the first Route will catch all of them, because all of them start with /. To avoid that, you need the keyword exact, like so:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement