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