Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import React, { Suspense, lazy } from 'react';
  2. import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
  3.  
  4. import './App.css';
  5.  
  6. // importing the Home component by default
  7. import Home from './Components/Home';
  8.  
  9. // importing other components using Dynamic Import
  10. const About = lazy(() =>
  11. import(/* webpackChunkName: "About" */ './Components/About'));
  12.  
  13. const Contact = lazy(() =>
  14. import(/* webpackChunkName: "Contact" */ './Components/ContactUs'));
  15.  
  16. const App = () => (
  17. <Router>
  18. <Suspense fallback={<div>Loading...</div>}>
  19. <Switch>
  20. <Route exact path="/" component={Home}/>
  21. <Route path="/about" component={About}/>
  22. <Route path="/contact" component={Contact}/>
  23. </Switch>
  24. </Suspense>
  25. </Router>
  26. );
  27.  
  28. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement