Created
September 27, 2019 17:31
-
-
Save 3nvi/8a9cd756cb05e7c11d9a9f3925fba695 to your computer and use it in GitHub Desktop.
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 withSuspense from './withSuspense'; // A HOC that just wraps the component with a `<React.Suspense />`. | |
const ProductListPage = React.lazy( | |
() => import('./ProductListPage') | |
); | |
const ProductDetailsPage = React.lazy( | |
() => import( './ProductDetailsPage') | |
); | |
const App = () => { | |
return ( | |
<Router> | |
<Route | |
path="products" | |
component={withSuspense(ProductListPage)} | |
/> | |
<Route | |
path="products/:id" | |
component={withSuspense(ProductDetailsPage)} | |
/> | |
</Router> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment