In my my App.js file I used this Switch logic:
<Switch>
<Route path='/' exact component={Dashboard}/>
<Route path='/question/:id' exact component={QPage}/>
<Route path='/new' exact component={CreateQ}/>
<Route path='/leaderboard' exact component={Leaderboard}/>
<Route component={Error}/>
</Switch>
The code above works as expected. My only problem is, when the Router accesses /question/:id and therefore renders the QPage component. Then, React throws an error of undefinded because inside of the QPage component, elements try to access the id and other props (which they take out of the url). How can I prevent the Router from accessing routes with invalid ids?