I created following with react router.
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
class Main extends Component {
render() {
return (
<Router>
<Switch>
<Route exact path='/' component={Content} />
<Route path='/user/:id' component={User} />
<Route path='*' component={NotFound} />
</Switch>
</Router>
);
}
export default Main
I want to open Notfound page if any invalid url.
I tried to open localhost:3000/err but, it will not go to NotFound compoenent.
My notfound component is simple.
import React from 'react';
const NotFound = () => (
<h2>404 Page Not Found</h2>
);
export default NotFound;
I am using "react-router-dom": "^4.3.1
"react-router-dom": "^4.3.1), and it works just fine (onlocalhost:3000/errI get "404 Page Not Found").Cannot GET /errCompiled successfully!on youryarn startcommand? And, above all, something likeYou can now view my-app in the browser.?i 「wdm」: Compiled successfully.localhost:3000/works fine?