SHARE
TWEET

Untitled

a guest Jun 20th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Before
  2.  
  3. import OtherComponent from './OtherComponent';
  4.  
  5. function MyComponent() {
  6.   return (
  7.     <div>
  8.       <OtherComponent />
  9.     </div>
  10.   );
  11. }
  12.  
  13. // After
  14.  
  15. const OtherComponent = React.lazy(() => import('./OtherComponent'));
  16.  
  17. function MyComponent() {
  18.   return (
  19.     <div>
  20.       <Suspense fallback={<div>Loading...</div>}>
  21.         <OtherComponent />
  22.       </Suspense>
  23.     </div>
  24.   );
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top