The MainRouter.js code will help render our custom React components with respect to routes or locations in the application. In this first version, we will only add the root route to render the Home component.
mern-skeleton/client/MainRouter.js:
import React, {Component} from 'react'import {Route, Switch} from 'react-router-dom'import Home from './core/Home'class MainRouter extends Component { render() { return (<div> <Switch> <Route exact path="/" component={Home}/> </Switch> </div>) }}export default MainRouter
As we develop more view components, we will update the MainRouter to add routes for the new components inside the Switch component.