Skip to content

Instantly share code, notes, and snippets.

@3nvi
Created September 27, 2019 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3nvi/8a9cd756cb05e7c11d9a9f3925fba695 to your computer and use it in GitHub Desktop.
Save 3nvi/8a9cd756cb05e7c11d9a9f3925fba695 to your computer and use it in GitHub Desktop.
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