Reputation: 1480
I am trying to set up a simple app using react-router, but no matter what I type in the URL, nothing is displayed where the BrowserRouter is set up.
Here is my code:
import React, { Component } from 'react';
import {BrowserRouter,Switch, Route} from 'react-router-dom';
import logo from './logo.svg';
import './App.css';
import MyApp from './MyApp';
import Deducciones from './Deducciones';
import MainMenu from './MainMenu';
class App extends Component {
render() {
return (
<div className="App">
<BrowserRouter>
<div>
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to My App</h1>
</header>
<Route exact path="/" Component={MainMenu} />
<Route exact path="/myapp" Component={MyApp} />
<Route exact path="/deduc" Component={Deducciones} />
</div>
</BrowserRouter>
</div>
);
}
}
export default App;
I tried typing http://localhost:3000/, http://localhost:3000/myapp, and http://localhost:3000/deduc into the url, but nothing is ever displayed except for the logo.
I also trying using a to enclose my routes but it was the same result. Can someone tell me what I am missing?
Upvotes: 0
Views: 456
Reputation: 3135
It should be component
lowercase not Component
upper case that why your router is probably not working
<Route exact path="/" component={MainMenu} />
<Route exact path="/myapp" component={MyApp} />
<Route exact path="/deduc" component={Deducciones} />
Upvotes: 5