I'm new with React. I'm using react-router-dom.
import React from 'react';
import { Router, Route, Switch, Link } from 'react-router-dom';
import Home from './components/home';
import Login from './components/login';
class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="app">
<Link to='/'>Home</Link>
<Link to='/login'>Login</Link>
<Switch>
<Route exact path='/' component={Home}/>
<Route path='/login' component={Login}/>
</Switch>
</div>
);
}
}
export default App;
I'm using this code everything work fine, but when I go to localhost:8080/login directly via de url I get a error Cannot GET /login but it goes well through a link <Link to='/login'>Login</Link>.
how can I fix it?
#fromhttp://localhost:8080/#/home