I can't seem to get my NotFound component to render. Whenever I type in some random characters in the url (ex: 'localhost:3000/asdfasdfasdfasdf'), the browser actually directs to my Topics component, with no content.
Here is how I have the routes set up:
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
render(){
return (
<div className="App">
<Router>
<NavBar />
<Switch>
<Route exact path='/' component={HomepageLayout} />
<Route exact path='/:topic' component={Topic} />
<Route path='*' component={NotFound} />
</Switch>
</Router>
</div>
);
}
export default App;
I've also tried not specifying a path, as some have advised, but this didn't work either:
<Route component={NotFound} />
Any ideas?