Skip to content

Instantly share code, notes, and snippets.

@cdaz5
Created April 8, 2019 21:05
Show Gist options
  • Save cdaz5/c11d416f7052c0df6f6eac3096568a43 to your computer and use it in GitHub Desktop.
Save cdaz5/c11d416f7052c0df6f6eac3096568a43 to your computer and use it in GitHub Desktop.
Step 1:
import React, { lazy, Suspense } from 'react';
Step 2:
// change this:
import BusinessList from 'screens/businesses/list';
// to this:
const BusinessList = lazy(() => import('screens/businesses/list'));
Step 3:
// wrap switch in <Suspense> and provide a fallback (in this a loader).
<Suspense fallback={<Loader />}>
<Switch>
// ...routes
</Switch>
</Suspense>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment