Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react lazy load suspense

import React from 'react';

// Dynamic import()
const CatAvatar = React.lazy(() => import('./path/to/cat/avatar'));

// Displays "loading..." to the user until CatAvatar
// has finished loading.
const AppContainer = () => (
  <React.Suspense fallback="loading...">
    <CatAvatar />
  </React.Suspense>
);
 
PREVIOUS NEXT
Tagged: #react #lazy #load #suspense
ADD COMMENT
Topic
Name
3+3 =