Learn Advanced React_ Advanced React_ Optimization Cheatsheet _ Codecademy
Learn Advanced React_ Advanced React_ Optimization Cheatsheet _ Codecademy
Memoization
Memoizing functions
Chunks
The <Suspense> React component wraps import { Suspense }, React from 'react';
components imported with React.lazy() .
<Suspense> instructs React to load the rest of the
React app and to display a loading state while the React const LargeComponent = React.lazy(await ()
component is downloaded and rendered. => import('./LargeComponent'));
<Suspense> takes one prop named fallback ,
which is a React component shown while its lazily loaded
children are unavailable. const Page = () => {
return {
<Suspense fallback={<p>Loading...
</p>}>
<LargeComponent />
</Suspense>
}
};
Print Share