Created
May 12, 2019 14:41
-
-
Save akhil-gautam/5fab846309c5ca35e65258268dbcc482 to your computer and use it in GitHub Desktop.
App.js file which is the root file which will be mounted to the dom and where routing will be configured.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Suspense, lazy } from 'react'; | |
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; | |
import './App.css'; | |
// importing the Home component by default | |
import Home from './Components/Home'; | |
// importing other components using Dynamic Import | |
const About = lazy(() => | |
import(/* webpackChunkName: "About" */ './Components/About')); | |
const Contact = lazy(() => | |
import(/* webpackChunkName: "Contact" */ './Components/ContactUs')); | |
const App = () => ( | |
<Router> | |
<Suspense fallback={<div>Loading...</div>}> | |
<Switch> | |
<Route exact path="/" component={Home}/> | |
<Route path="/about" component={About}/> | |
<Route path="/contact" component={Contact}/> | |
</Switch> | |
</Suspense> | |
</Router> | |
); | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment