Last active
September 13, 2020 10:28
-
-
Save srezasm/8f4b5dc5f5c7d1e362b83a503df3dc12 to your computer and use it in GitHub Desktop.
lazyLoadingRoutes After
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 from "react"; | |
import { BrowserRouter, Route, Link, Switch } from "react-router-dom"; | |
const AskPage = React.lazy(() => import("./AskPage")); | |
const App = () => { | |
return ( | |
<BrowserRouter> | |
<Link to="/ask">AskPage</Link> | |
<Route exact path="/ask"> | |
<React.Suspense fallback={<div style={{ marginTop: "100px", textAlign: "center" }}>Loading...</div>}> | |
<AskPage /> | |
</React.Suspense> | |
</Route> | |
</BrowserRouter> | |
); | |
}; | |
export default App; |
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 from "react"; | |
export const AskPage = () => <h1> This is AskPage </h1>; | |
export default AskPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment