0

I cant navigate to the Route path it doesn't respond to it I dont know why. Anyone know what is wrong with my code. It just load the landing page and that about it cant load other components

import React, { Component } from "react";
import { BrowserRouter as Router, Route } from 'react-router-dom';

import Navbar from "./components/layout/Navbar";
import Footer from "./components/layout/Footer";
import Landing from "./components/layout/Landing";
import Register from "./components/auth/Register";
import Login from "./components/auth/Login";
import "./App.css";


class App extends Component {
  render() {
    return (
      <Router>
        <div className="App">
          <Navbar />
          <Route path="/" component={Landing} />
          <div className="container">
          <Route path="/register" component={Register}/>
          <Route path="/login" component={Login}/>
          </div>
          <Footer />
        </div>
        </Router>
    );
  }
}

export default App;
Sambulo Senda
  • 1,240
  • 1
  • 13
  • 17

1 Answers1

2

Add the exact to your intial route, else it gets caught in all the paths,

<Route exact path="/" component={Landing} />
Rohith Murali
  • 4,864
  • 2
  • 18
  • 23